ID: Q122709
The information in this article applies to:
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.
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.
"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
Version : 6.0 6.0a 6.0c 7.0 7.0a
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: February 6, 1998