View Single Post
  #6   Report Post  
Posted to microsoft.public.word.newusers
BK BK is offline
external usenet poster
 
Posts: 144
Default Save Printer with document

Thanks for all this information. Seems like it would be a lot easier to
just change the printer preference when I open the document! grin


"Graham Mayor" wrote in message
...
I thought when I posted earlier that I had included this on my web site. I
looked for it on the wrong page (

The correct link would be http://www.gmayor.com/Associate_Printer.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org






Graham Mayor wrote:
Just in case I don't get around to my web page, the code required
(store in the normal template or the relevant document template)
would be as follows. The first macro will record the named printer in
the current document. Run the macro and save the document. The other
two macros intercept the fileprint and fileprintdefault commands that
print the document to establish whether the variable is present in
the current document and if it is print to that document. It makes no
allowance for a named printer not being available, though extra error
trapping could be included.
Sub SetHPAsDocumentPrinter()
Dim oVars As Variables
Set oVars = ActiveDocument.Variables
oVars("varPrinter").Value = "HP LaserJet 4050 Series PCL"
End Sub

Sub FilePrintDefault()
Dim oVars As Variables
Dim vVar As Variant
Dim bExists As Boolean
Dim sPrinter As String
sPrinter = ActivePrinter
Set oVars = ActiveDocument.Variables
bExists = False
For Each vVar In oVars
If vVar.name = "varPrinter" Then
bExists = True
With Dialogs(wdDialogFilePrintSetup)
sPrinter = .Printer
.Printer = oVars("VarPrinter").Value
.DoNotSetAsSysDefault = True
.Execute
'MsgBox "Printing to " & ActivePrinter
ActiveDocument.PrintOut
.Printer = sPrinter
.DoNotSetAsSysDefault = True
.Execute
End With
Exit For
End If
Next vVar
If bExists = False Then
'MsgBox "Printing to " & ActivePrinter
ActiveDocument.PrintOut
End If
End Sub

Sub FilePrint()
Dim oVars As Variables
Dim vVar As Variant
Dim bExists As Boolean
Dim sPrinter As String
sPrinter = ActivePrinter
Set oVars = ActiveDocument.Variables
bExists = False
For Each vVar In oVars
If vVar.name = "varPrinter" Then
bExists = True
With Dialogs(wdDialogFilePrintSetup)
sPrinter = .Printer
.Printer = oVars("VarPrinter").Value
.DoNotSetAsSysDefault = True
.Execute
Dialogs(wdDialogFilePrint).Show
.Printer = sPrinter
.DoNotSetAsSysDefault = True
.Execute
End With
Exit For
End If
Next vVar
If bExists = False Then Dialogs(wdDialogFilePrint).Show
End Sub

http://www.gmayor.com/installing_macro.htm



Graham Mayor wrote:
While strictly that is accurate, it can be worked around by saving
the printer information in a document variable or custom property and
interrogating the document variables/properties at print time to see
if a printer has been recorded and selecting that printer for the
job. Actually I thought I had included the macros to provide this
function on my http://www.gmayor.com/fax_from_word.htm page, but
apparently I haven't. Seems like a task for the weekend


Suzanne S. Barnhill wrote:
Unfortunately, no, it is not possible to save printer selection with
a document.


"BK" wrote in message
...
Using Windows XP and Office 2007

We have a number of network printers. Is it possible to save the
specific selected printer with a Word document so that when I open
that document, it will already have the correct printer selected?