View Single Post
  #1 (permalink)  
Old July 1st, 2010, 09:54 AM
flash211 flash211 is offline
Registered User
 
Join Date: Jul 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB Script for selecting printer

I have a 30-page Excel report that is printed daily. It could be printed from one of many workstations (each station having a different "default" printer). I would like to write a macro in Excel to automatically select the correct printer and printing mode ("2-sided, flip on short edge").

I tried the SendKeys process, but the program locks up on the last "enter" function. It works fine if I do the last step manually by depressing the enter key. Odd. . . .

I would prefer to use something other than Sendkeys, but I have not found anything that will help (probably because of my minimal experience with coding . . . ).

Here is what I have:

~~~~~~~~~~~~~~~~~~~~~
Sub xxx()

' xxx Macro
' Macro recorded 6/3/2010 by YYYYY

Application.ActivePrinter = "\\EEKIRK1PRN01\KGO2P56 on Ne03:"
SendKeys "%FP"
Application.Wait Now + TimeValue("00:00:01")
SendKeys "%R"
Application.Wait Now + TimeValue("00:00:02")
SendKeys "{TAB 2}"
SendKeys "{DOWN 2}"
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{TAB 9}"
Application.Wait Now + TimeValue("00:00:03")
Application.SendKeys "{~}", True
End Sub
~~~~~~~~~~~~~~~~~~~~~

As I mentioned, it locks up (e.g., get message that system not responding) when the macro performs the "enter" function. The system works fine if I manually enter the "enter" function. I have also looked at xldialog settings, but to no avail.

Any assistance would be deeply appreciated,

Thank you!
Reply With Quote