Flash211
06-04-2010, 10:12 AM
Hello Folks, I am new to this and am hopeful that someone can provide some guidance. I apologize upfront if this is the wrong forum.
I have an Excel spreadsheet that has many tabs for which many of them are printed each day. I would like to have printed the various tabs to print in the duplex mode. In fact, I would like any of the 12 employees in this area to be able to print the various reports.
We all are connected to a Xerox Workcentre Pro 275 printer, via the lan, that can print in duplex.
I tried recording a macro in Excel, but I have learned that the macro is not recorded while changing the printer details.
I therefore moved onto a less useful method by sending the keystrokes (SendKey). That seems to work, but up to a point (the ENTER Function). Here is the VERY SIMPLE code:
Sub xxx()
' xxx Macro
' Macro recorded 6/3/2010 by XXXX
'Select Printer
Application.ActivePrinter = "\\EEKIRK1PRN01\KGO2P56 on Ne03:"
'Open Printer Dialog Box
SendKeys "%FP"
Application.Wait Now + TimeValue("00:00:01")
'Open Printer Properties
SendKeys "%R"
Application.Wait Now + TimeValue("00:00:02")
'Open Printing Mode
SendKeys "{TAB 2}"
'Select Printing Mode (2 Sided Print, Flip on Short Edge)
SendKeys "{DOWN 2}"
Application.Wait Now + TimeValue("00:00:01")
'Change focus of dialog box to OK)
SendKeys "{TAB 9}"
Application.Wait Now + TimeValue("00:00:03")
'Enter to close this dialog box
Application.SendKeys "{~}", True
End Sub
I have tried many different approaches for the "ENTER" function (i.e., VbCrLf, {ENTER}, etc.) but in all cases, once the focus is on the OK and ENTER is sent, the system locks up. In all cases, the excel spreadsheet quits responding. I can manually do it and everything is fine. I am just not sure if the sendkey function is having an issue with the Xerox printer.
Any suggestions?
Once again, sorry if this is not the correct forum.
Thank you,
Pat
Welcome to the forum, Pat. Your question is about Excel VBA, so I have moved it from the VB .Net General board to the Excel VBA board.
If you have questions about Excel VBA then this is the board to post them in.
I have also added code /code around your code to make it easier to read.
I have an Excel spreadsheet that has many tabs for which many of them are printed each day. I would like to have printed the various tabs to print in the duplex mode. In fact, I would like any of the 12 employees in this area to be able to print the various reports.
We all are connected to a Xerox Workcentre Pro 275 printer, via the lan, that can print in duplex.
I tried recording a macro in Excel, but I have learned that the macro is not recorded while changing the printer details.
I therefore moved onto a less useful method by sending the keystrokes (SendKey). That seems to work, but up to a point (the ENTER Function). Here is the VERY SIMPLE code:
Sub xxx()
' xxx Macro
' Macro recorded 6/3/2010 by XXXX
'Select Printer
Application.ActivePrinter = "\\EEKIRK1PRN01\KGO2P56 on Ne03:"
'Open Printer Dialog Box
SendKeys "%FP"
Application.Wait Now + TimeValue("00:00:01")
'Open Printer Properties
SendKeys "%R"
Application.Wait Now + TimeValue("00:00:02")
'Open Printing Mode
SendKeys "{TAB 2}"
'Select Printing Mode (2 Sided Print, Flip on Short Edge)
SendKeys "{DOWN 2}"
Application.Wait Now + TimeValue("00:00:01")
'Change focus of dialog box to OK)
SendKeys "{TAB 9}"
Application.Wait Now + TimeValue("00:00:03")
'Enter to close this dialog box
Application.SendKeys "{~}", True
End Sub
I have tried many different approaches for the "ENTER" function (i.e., VbCrLf, {ENTER}, etc.) but in all cases, once the focus is on the OK and ENTER is sent, the system locks up. In all cases, the excel spreadsheet quits responding. I can manually do it and everything is fine. I am just not sure if the sendkey function is having an issue with the Xerox printer.
Any suggestions?
Once again, sorry if this is not the correct forum.
Thank you,
Pat
Welcome to the forum, Pat. Your question is about Excel VBA, so I have moved it from the VB .Net General board to the Excel VBA board.
If you have questions about Excel VBA then this is the board to post them in.
I have also added code /code around your code to make it easier to read.