Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Warn wrong printer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
matthew.rodwell@luptonfawcett.com - 07 Nov 2007 13:43 GMT
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
Graham Mayor - 07 Nov 2007 14:39 GMT
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.

Signature

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

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

> I am looking 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
matthew.rodwell@luptonfawcett.com - 07 Nov 2007 14:47 GMT
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
Graham Mayor - 07 Nov 2007 15:01 GMT
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?

Signature

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

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

> 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
matthew.rodwell@luptonfawcett.com - 13 Nov 2007 11:00 GMT
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
Graham Mayor - 13 Nov 2007 14:28 GMT
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.

Signature

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

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

> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.