Using SEND.KEYS() to Change Paper Source in Printer Setup

ID: Q69614


The information in this article applies to:


SUMMARY

The following macro will change the paper source to "lower tray" on the Helwett-Packard (HP) LaserJet IIP:


   A1: =SEND.KEYS("%(S)~%(S){PGUP}{DOWN}~~")
   A2: =PRINTER.SETUP?()
   A3: =RETURN() 


This macro sends keystrokes to the Printer Setup dialog box. The following is an explanation of the string used in the SEND.KEYS() function:


   Command        Description
   -------        -----------

   %(S)           Chooses Setup
   ~              Chooses OK (Excel 3.00 only, see below **)
   %(S)           Selects "paper source"
   {PGUP}         Moves selection to the top to choose "upper tray"
   {DOWN}         Moves selection down one time to choose "lower tray"
   ~~             Chooses OK twice to enter the changes. 


** This is only needed in Microsoft Excel version 3.0 with printers that support extended printer attributes accessible in Page Setup from the File menu. Epson printer drivers, for example, do not support these attributes; therefore, the tilde is not necessary. If you are not sure if your printer has these attributes, you can manually choose Printer Setup from the File menu and choose the setup button. If a dialog box is displayed with the following message, you need the tilde:

This command controls default printer settings for all documents and all applications. Use File Page Setup to set Orientation, Paper Size, and Scaling for individual documents.


MORE INFORMATION

In 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 keys should be used to select from the list of sources available. On the HP LaserJet IIP, for example, there are four possible choices for the paper source:

The problem is that the current selection is unknown. The following may be the easiest way to select the right choice from the paper source list:

  1. Assume that the current selection is not known. To change that assumption, select the first source ("upper tray"). PGUP will guarantee that "upper tray" is selected.

    Use "{PGUP}" (without the quotation marks) in the SEND.KEYS string.


  2. Note how many times you want to use the {DOWN} string. The following is an example:

    
          none                 for "Upper tray"
          {DOWN}               for "Lower tray"
          (DOWN){DOWN)         for "Manual feed"
          {DOWN}{DOWN}{DOWN}   for "Envelope" 


Notes

  1. The number of {DOWN} entries equals the choice number in the list box, minus one (that is, number of {DOWN} entries = [choice number in list box] - 1).


  2. It is assumed that the right printer is selected.


  3. Do not use the STEP() function before this macro or the keys sent will not work.



REFERENCES

"Function Reference," version 4.0, page 385
"Microsoft Excel Function Reference," version 3.0, pages 214-215.

"Microsoft Excel for Windows Functions and Macros," version 2.1x, pages 353-254, 373-375

Additional query words: 2.0 2.00 2.01 2.1 2.10 3.0 4.0


Keywords          : 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: March 21, 1999