XL5: Using SENDKEYS to Change Paper Source in Printer SetupLast reviewed: September 2, 1997Article ID: Q105878 |
The information in this article applies to:
SUMMARYIn Microsoft Excel, you can use the following Visual Basic, Applications Edition, macros to change the paper source on the Hewlett-Packard (HP) LaserJet 4/4M to the lower tray.
Sample MacrosMicrosoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose. To send key commands to the Printer Setup dialog box, use the following code:
Sub HP4_Paper_Source() Application.Wait Now + Timevalue("00:00:01") Application.ActivePrinter = "HP LaserJet 4/4M on LPT1:" SendKeys "%(f)(p)(r)%(s)%(s){pgup}{down}{down} {down}{down}~~~" End SubIn order to use this Macro with a shortcut key, you must put a wait statement before the Application.ActivePrinter line. The wait may have to be adjusted depending on the system environment. For example, to make the macro wait one second, use the following line of code:
Application.Wait Now + Timevalue("00:00:01")The following is an explanation of the string used in the SendKeys function:
This command Performs this action ---------------------------------------------------- %(f)(p)(r) Chooses Printer Setup in the Print dialog %(s) Chooses Setup in the Printer Setup dialog %(s) Chooses Paper Source in the HP 4/4M Setup dialog {pgup} Moves Paper Source selection up {down} Moves Paper Source selection downTo set the paper source, and then set it back to Auto Select, use the following code:
Sub HP4_Paper_Source() Application.Wait Now + TimeValue("00:00:01") Application.ActivePrinter = "HP LaserJet 4Si/4Si MX on LPT1:" SendKeys "%(f)(p)(r)%(s)%(s){pgup}{down}{down}{down}{down}~~~" Application.OnTime Now + TimeValue("00:00:08"), "setback" ' SendKeys "%(f)(p)(r)%(s)%(s){pgup}~~~" End Sub Sub setback() Application.Wait Now + TimeValue("00:00:01") Application.ActivePrinter = "HP LaserJet 4Si/4Si MX on LPT1:" SendKeys "%(f)(p)(r)%(s)%(s){pgup}~~~" End Sub MORE INFORMATIONIn the Printer Setup dialog box, there is no accelerator key combination that will directly select a paper source such as lower tray. Instead, the arrow key should be used to select from the list of available sources. For example, on the HP LaserJet 4/4M there are six possible choices for the paper source:
NOTE: This macro may work for other printers or may require a different sequence of keystrokes depending on the printer driver.
REFERENCES"Visual Basic User's Guide," version 5.0, Chapter 6
|
Additional reference words: 5.00 print
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |