SUMMARY
In 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 Macros
Microsoft 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 Sub
In 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 down
To 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