Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

Warn wrong printer

 
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba beginners
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed Nov 07, 2007 1:43 pm    Post subject: Warn wrong printer Reply with quote

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
Back to top
Google
Sponsor





PostPosted: Wed Nov 07, 2007 1:43 pm    Post subject: Advertisement

Back to top
Graham Mayor
Guest





PostPosted: Wed Nov 07, 2007 2:39 pm    Post subject: Re: Warn wrong printer Reply with quote

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


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

matthew.rodwell@luptonfawcett.com wrote:
Quote:
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
Back to top
Guest






PostPosted: Wed Nov 07, 2007 2:47 pm    Post subject: Re: Warn wrong printer Reply with quote

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
Back to top
Graham Mayor
Guest





PostPosted: Wed Nov 07, 2007 3:01 pm    Post subject: Re: Warn wrong printer Reply with quote

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

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



matthew.rodwell@luptonfawcett.com wrote:
Quote:
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
Back to top
Guest






PostPosted: Tue Nov 13, 2007 11:00 am    Post subject: Re: Warn wrong printer Reply with quote

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
Back to top
Graham Mayor
Guest





PostPosted: Tue Nov 13, 2007 2:28 pm    Post subject: Re: Warn wrong printer Reply with quote

I see we have two threads on this topic Sad. 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

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




matthew.rodwell@luptonfawcett.com wrote:
Quote:
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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba beginners All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum