Q: Can I assign a printer to a document so that it will use the printer I want?
A: Not directly. What I've done instead is implement a floating toolbar button that is enabled
and made visible by the documents going to the special printer. In my case, I
use one printer just for envelopes so it is in my envelope templates.
The macro called by it collects the current printer setting in a variable,
changes the printer to the envelope printer, prints the document, and then
changes the printer setting back.
The macros and toolbar button are stored in a global
template and called by the document template.
Print macro in global template:
SubEnvPrint ()
Dim sMyActivePrinter As String
Selection.Collapse
sMyActivePrinter = ActivePrinter
ActivePrinter = "HP LaserJet IIIP"
Application.PrintOut FileName:="", _
Range:=wdPrintCurrentPage, Item:= _
wdPrintDocumentContent, Copies:=1, _
Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, _
PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActivePrinter = sMyActivePrinter
End Sub
Also in the global:
Sub EnvelopeOpen()
Application.CommandBars("Envelope
Toolbar").Enabled = True
Application.CommandBars("Envelope
Toolbar").Visible = True
End Sub
The envelope template has AutoNew and AutoOpen macros:
Sub AutoNew()
Application.Run MacroName:="EnvelopeOpen"
End Sub
Sub AutoOpen()
Application.Run MacroName:="EnvelopeOpen"
End Sub
In the AutoExec macro for the global are the following:
Word.CommandBars("Envelope Toolbar").Enabled =
False
Word.CommandBars("Envelope Toolbar").Visible =
False
This keeps the toolbar from being in the way unless it is
needed. I could hide it again when the document is closed but it's just as easy
to click on the close box on the toolbar.
This way, I don't end up sending my letters to the
envelope printer because the printer settings go back to what they were. Also, this way the bulk of the code is
centrally located so if I change the printer I only need to change the code in
one spot rather than in multiple envelope templates.
If needed, I suppose you could have the macro call up the
print dialog instead of printing.
For more on global templates see: http://www.addbalance.com/usersguide/templates.htm
For instructions on inserting these macros in your
documents or templates see: Macros and VBA
This page viewed
times since 13 April 2004.
|