Microsoft KB Archive/26725

Changing Printer Setup Through an Excel for Windows Macro PSS ID Number: Q26725 Article last modified on 02-26-1993 PSS database name: W_eXceL

2.x 3.00 | 2.20 2.21 3.00

WINDOWS | OS/2

Summary:

Note: The following macro will not work if the STEP function is used in the macro.

You can change settings in the Printer Setup dialog box using the SEND.KEYS macro function by sending the keystrokes before you call the PRINTER.SETUP? dialog box. For example, if you want to change the printer to landscape mode, set up the following two macro lines:

Excel 3.0
Excel 3.0 displays an alert after Setup is selected from the printer setup dialog box that is displayed when you select Printer Setup. In order to handle this alert box with this Send.Keys formula it is necessary to add a ~ between the %(S) and %(L) in the formula. ie; SEND.KEYS(“%(S)%(L)~”).

Excel 2.x
=SEND.KEYS(“%(s)%(l)”) =PRINTER.SETUP?

The following is an explanation of the text string, “%(s)%(l)”:


 * 1) The “%(s)” means to press ALT+S (hold down the ALT key and press S). This command brings up the Printer Setup dialog box.
 * 2) “%(l)” is ALT+L, which specifies landscape mode. For the PCL/HP LaserJet driver in Windows Version 2.10 and Excel Version 2.10, the landscape code is N and the portrait code is R.
 * 3) The tilde character (~) is equivalent to pressing the ENTER key, which closes the dialog box. Please note that there are two tilde characters, one for each successive dialog box that comes up.

The printer driver must conform to the standard accelerator key interface; if not, change the keystrokes appropriately. With this technique, you can send the printer the precise keystrokes to set it up the way you wish.

Copyright Microsoft Corporation 1993.