How to Create a Macro to Change Printer or Fax Driver

Last reviewed: February 5, 1998
Article ID: Q122709
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, versions 7.0, 7.0a

SUMMARY

This article describes how to create a macro that allows you to send a document to a specific printer or fax device and then resets the printer to the original default. If you have several printers or if you want to switch between a printer and a fax driver, create multiple macros.

MORE INFORMATION

The following macro example selects the "HP LaserJet IIISi on LPT1:" and then returns you to your default printer.

Sub MAIN
   'Retrieve and set information about the current default printer
   Dim FPS As FilePrintSetup
   GetCurValues FPS
   'Set the default Printer
   DefaultPrinter$ = FPS.Printer
   FilePrintSetup .Printer = "HP LaserJet IIISi on LPT1:"
   'Send the document to the currently selected printer
   FilePrint
   'Reset to the original default printer
   FilePrintSetup .Printer = DefaultPrinter$
End Sub

If you have more than one printer, you can create one macro for each printer and change the name of the printer to reflect the printer you are using. Make sure the text exactly matches the printer description. To obtain this information, click Print on the File menu and then choose the Printer button.

To create the macro:

  1. On the Tools menu, click Macro.

  2. Type a macro name, such as PrintToFax (without any spaces), and click Edit. A macro editing window will appear.

  3. Type the lines shown above between the Sub MAIN and End Sub lines.

  4. Click Close and save your changes to the macro.

Once you create the macro, you can use the Customize command (on the Tools menu) to assign the macro to a keystroke, menu, or toolbar button.

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.

REFERENCES

"Microsoft Word Developer's Kit," version 6.0, page 439


KBCategory: kbprg
KBSubcategory: kbmacroexample
Additional reference words: 6.0 6.0a 6.0c word7 word95 winword ntword
wordnt word6 macro printer switch fax default change
Keywords : kbmacroexample kbprg
Version : 6.0 6.0a 6.0c 7.0 7.0a
Platform : WINDOWS
Issue type : kbhowto


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.