How to make a document 'remember' which printer.

T

ThomasAJ

We have many printers. How do I make a document remember which printer it
should use when the print icon is clicked on.

Sure I can use the printer drop-down box but I want certain documents to
remember their own 'default printer'.
 
G

Graham Mayor

The required printer is not something stored with the document. You can
intercept the print commands in the documents' templates to address the
required printers, and you could do so in the documents themselves, but that
would raise macro security issues - see
http://www.gmayor.com/fax_from_word.htm for some examples.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter A

We have many printers. How do I make a document remember which printer it
should use when the print icon is clicked on.

Sure I can use the printer drop-down box but I want certain documents to
remember their own 'default printer'.

You cannot do this. If each document "remembered" a specific printer, it
would cause problems when the document went to another person.
 
B

Bob Buckland ?:-\)

Hi Graham,

One method that I think Cindy(?) was using was to store the printer name in a custom document property then look for it in a macro.

If it doesn't already do so, couldn't the printer toolbar type macro in your examples include looking for that property and if it
found in the document property a name that matched a printer (or an array of choices that equalled a printer) then go on to
'suggest'/highlight the 'normally' selected printer (and also variables for trays?) for that document on that toolbar?

That would seem to avoid having a macro in a document and also wouldn't affect others who did not run the toolbar macro?

=================
The required printer is not something stored with the document. You can
intercept the print commands in the documents' templates to address the
required printers, and you could do so in the documents themselves, but that
would raise macro security issues - see
http://www.gmayor.com/fax_from_word.htm for some examples.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP >>
--

Bob Buckland ?:)
MS Office System Products MVP

*Courtesy is not expensive and can pay big dividends*
 
T

ThomasAJ

You cannot do this. If each document "remembered" a specific printer, it
would cause problems when the document went to another person.

Rubbish! If 'remembered' printer is not present then Word would use the
default printer. It might be called a 'Preferred Printer' and reside in
OPTIONS. A 5 minute programming exercise is all it would have taken.

OK so make that 10 minutes of coding.

Very disappointing ommision by MS.

I've been coding since about '75 so I know what I am talking about.
 
G

Graham Mayor

I would have thought that such an experienced coder would have been able to
arrange something suitable and saved me the bother, but the following macro
in the document template (or at a pinch in the document itself - though that
raises the spectre of macro security) will do the job. The macro intercepts
the print button and looks for the string "COLOR" in the available printers
(converting to printer names to upper case) . You can change that string to
match the printer you require for the document.

Sub FilePrintDefault()
Dim StrPrinters As Variant, i As Long
Dim sPrinter As String
Dim sNone As String
StrPrinters = ListPrinters
sPrinter = ActivePrinter
If IsBounded(StrPrinters) Then
For i = LBound(StrPrinters) To UBound(StrPrinters)
If InStr(UCase(StrPrinters(i)), "COLOR") Then
ActivePrinter = StrPrinters(i)
GoTo PrintDoc
End If
Next i
sNone = MsgBox("Required printer not available" & vbCr & vbCr & _
"Print to default Word printer?", vbYesNo, "Printer
Error")
If sNone <> vbYes Then
MsgBox "Print cancelled"
ActivePrinter = sPrinter
Exit Sub
Else
GoTo PrintDoc
End If
Else
MsgBox "No printers found"
End If
Exit Sub
PrintDoc:
MsgBox "Printing to " & ActivePrinter
ActiveDocument.PrintOut
ActivePrinter = sPrinter
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
T

ThomasAJ

Thanks for the code Graham.

Also please resist the urge to jump to conclusions regarding the
'experienced coder' aspect. I am very experienced but... not in Word VB.
 
B

Bob Buckland ?:-\)

Hi Graham,

Very nice :) When I suggested something on this line on the 18th, it seemed that I was forgetting something and of course now I do
recall it (sorry :( )

What we ended up having to do was to store the variable as hidden within the document (may have been a bookmark) rather than as a
document property to keep the 'remove hidden data' routine (now in Word 2007's
Office Button=>Prepare=>Inspect document)
from taking out the saved name again.

The document inspector can be customized but I'd suspect that it may be something some companies have setup to run the default
inspection somewhat automatically.

===============
I have just added a page to my site with an add-in that will associate a
document with the required printer and print using that printer if it is
available. http://www.gmayor.com/Associate_Printer.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP >>
--

Bob Buckland ?:)
MS Office Products MVP

*Courtesy is not expensive and can pay big dividends*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top