Warn wrong printer

  • Thread starter matthew.rodwell
  • Start date
M

matthew.rodwell

I am llooking for a piece of code to warn a person that when they are
printing that the printer they have select is the wrong one and to
either warn them or send it to the correct printer....VERY URGENT
log ...thanks in advance
 
G

Graham Mayor

As you will have to intercept the print commands to warn of an incorrect
printer, it is probably simpler to set the required printer for a particular
document by intercepting the print command in that document's template, then
the printer will always be correct.

e.g. the following will print the document to the HP Laser Jet 4050 Series
PCL printer when the print button is clicked.

Sub FilePrintDefault()
Dim sCurrentPrinter As String
On Cancel GoTo Cancelled:
sCurrentPrinter = ActivePrinter
ActivePrinter = "HP Laser Jet 4050 Series PCL"
Application.PrintOut FileName:=""
Cancelled:
With Dialogs(wdDialogFilePrintSetup)
.Printer = sCurrentPrinter
.DoNotSetAsSysDefault = False
.Execute
End With
End Sub

You will find some background at http://www.gmayor.com/fax_from_word.htm or
if you want more information tell us exactly what it is you are doing.

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



<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

matthew.rodwell

now that woul work great if we didn't always have a macro for the
printing...which is why we wanted to give thenm an error message to
say this was the wrong printer.what happens is we run a macro to find
and replace a certain word wit another then we would like it to stop
the person printing to the wrong printer...if thats makes sense
 
G

Graham Mayor

It doesn't make sense. I am not at all clear what you are saying here.

The macro code I posted sends the document to the indicated printer. It is
named to intercept the print command

I am not sure what your replace macro has to do with printing the document.
If your macro prints the document then set the correct printer in that macro
as shown. Rather than simply tell the user that the wrong printer is
selected, select the correct one?

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

matthew.rodwell

Ok i'll slightly change my question....If say someone sends the print
job to a printer we do not want them to print it on, i would like the
macro to pick up a certain word then stop the print thorugh up an
error message then return to the document.

think that sounds better
 
G

Graham Mayor

I see we have two threads on this topic :(. Can you stick to one please.

If you set the macro in the document template as described earlier, the
document won't be printed to the wrong printer. The only way you can
establish whether you are printing to the correct printer is to intercept
the print routines and if you are going to do that, you might as well just
force the use of the correct printer. Your warning then becomes
superfluous.. The macro I posted earlier logs the current printer, changes
to the required printer (here an HP Laserjet), prints the document then
restores the original printer. It runs when you click the print button or
CTRL+P.

Sub FilePrintDefault()
Dim sCurrentPrinter As String
On Cancel GoTo Cancelled:
sCurrentPrinter = ActivePrinter
ActivePrinter = "HP Laser Jet 4050 Series PCL"
Application.PrintOut FileName:=""
Cancelled:
With Dialogs(wdDialogFilePrintSetup)
.Printer = sCurrentPrinter
.DoNotSetAsSysDefault = False
.Execute
End With
End Sub

To intercept the File > Print command you need a separate macro

Sub FilePrint()
Dim sCurrentPrinter As String
On Cancel GoTo Cancelled:
sCurrentPrinter = ActivePrinter
ActivePrinter = "HP Laser Jet 4050 Series PCL"
Dialogs(wdDialogFilePrint).Show
Cancelled:
With Dialogs(wdDialogFilePrintSetup)
.Printer = sCurrentPrinter
.DoNotSetAsSysDefault = False
.Execute
End With
End Sub

Note that these macros go in the document template - not normal.dot.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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