Microsoft KB Archive/96923

{|
 * width="100%"|

Error Sending Keys to FilePrinterSetup with No Default Printer

 * }

Q96923

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows, version 7.0

-

SUMMARY
You can change printer driver settings such as resolution, paper orientation, and paper size with a Microsoft WordBasic macro that includes the SendKeys command.

Word versions 6.0, 7.0 and NT
When you are using the SendKeys command, and there is no active printer, you will receive the following error message:

WordBasic Err = 102, Command Failed

Word versions 1.x
If no default printer has been set or no printer is active, a macro that uses the SendKeys command to access a printer driver in Word version 1.x for Windows will cause an unrecoverable application error (UAE) (if you are using Microsoft Windows version 3.0) or a general protection (GP) fault (if you are using Windows version 3.1).

MORE INFORMATION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

The SendKeys command should only be used to change settings that are not available in the Page Setup dialog box (from the Format menu, choose Page Setup) of Word version 2.0 for Windows. For example, the following macro automates the process of changing the duplex option in the HP LaserJet IIISi printer driver:

  Sub MAIN SendKeys &quot;%o&quot;, - 1                'Options button SendKeys &quot;%l{enter}{enter}&quot;, - 1  'chooses long side and OK button FilePrintSetup .Printer = &quot;HP LaserJet IIISi on LPT1:&quot;, .Setup End Sub