Error Sending Keys to FilePrinterSetup with No Default Printer

Last reviewed: February 5, 1998
Article ID: 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 95, 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 "as is" 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 "%o", - 1                 'Options button
   SendKeys "%l{enter}{enter}", - 1   'chooses long side and OK button
   FilePrintSetup .Printer = "HP LaserJet IIISi on LPT1:", .Setup
   End Sub

REFERENCES

"Using WordBasic" by WexTech Systems, Inc. and Microsoft Corporation, Microsoft Press, 1992.


KBCategory:
KBSubcategory: kbmacro
Additional query words: winword2 send keys 1.0 1.10 word6 winword
7.0 word95 word7 1.10a 2.0 2.0a 2.0a-CD 2.0b 2.0c 6.0 6.0a 6.0c
Keywords : kbmacro kbprint
Version : 1.x 2.x 6.0 6.0a 6.0c 7.0
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.