Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to Execute code and then add more VBA

Status
Not open for further replies.

kw2oak

Programmer
Mar 22, 2002
9
GB
I have code that for various reasons has to use the sendKeys function (setting printer settings that are not programmable) and I wish to unset them again using the same method.
I have my routine using sendkeys and then using the ApplicationPrintout method (Word) and then use SendKeys to reset the printer settings.
However the resetting seems to take place before the printing.
If I put a 'wait' command using the timer after issuing the Printout command the whole routine hangs until the timer function is complete. The same happens when I use a message-box to display a message - I need to 'release' the code in some way to perform the printout method and then be allowe dto contimnue to rest the printer settings.
Any ideas?
 


Please post your code.

Skip,

[glasses] [red]Be Advised![/red] For those this winter, caught in Arctic-like calamity, be consoled...
Many are cold, but few are frozen![tongue]
 
Skip
Thanks for your request.
Unfortunately I cannot post my code as it is back at the office where I am working.

In short it is code that establishes the active printer and sets the paper tray from which the user want to use.

Where the printer is a Kyocera it has 9 output 'bins' and unless I try to use kyocera's own programming language (Prescribe) which will not work from within a word macro I have to change the output bin by sending key strokes using Sendkeys - this works fine

I then use the application.printout method to print the document. This works fine.

But!
If the user asks for duplex (they have a user-form on which they can make selections) this is where I am having the difficulties.

I set the output bin
I set the duplex option also through keystokes
I use Application.printout
This all works OK

except of course it leaves the duplexing option set on, whilst users could turn this off manually this goes against what the client wants - the automation of printing.

I have added code after the Application.Printout line that uses SendKeys to reset the Duplex back to off but when this code is added the document is printed but it is not Duplexed.
From what I can see the printout instruction does not get executed until the code is finished and by this time the duplexing is turned off again.
There appears to be no way I can check any property setting to see if the printer is set to duplex mode and as such I cannot place code in my code to turn it off if it is on!

Does this all make sense - do you have any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top