Default printer changing

A

Addy

I have loads of printing macros which are all working great now thanks to
help from this site. I have a macro which opens up the dialog box of a
colour photocopier so that you can do any special printing such as duplex,
staple, holepunch etc. The macro seems to be sticking to the colour printer
and so when I use one of the other macros to print to the laser printer it
prints to teh colour printer. Anyone any ideas why please. My macro is below
cheers in advance

Private Sub CMDCOLSPECIAL_Click()

With Dialogs(wdDialogFilePrintSetup)
.Printer = "\\rother\Canon"
.DoNotSetAsSysDefault = True
.Execute

Dialogs(wdDialogFilePrint).Show

End With

End Sub
 
J

Jonathan West

Addy said:
I have loads of printing macros which are all working great now thanks to
help from this site. I have a macro which opens up the dialog box of a
colour photocopier so that you can do any special printing such as duplex,
staple, holepunch etc. The macro seems to be sticking to the colour
printer
and so when I use one of the other macros to print to the laser printer it
prints to teh colour printer. Anyone any ideas why please. My macro is
below
cheers in advance

Private Sub CMDCOLSPECIAL_Click()

With Dialogs(wdDialogFilePrintSetup)
.Printer = "\\rother\Canon"
.DoNotSetAsSysDefault = True
.Execute

Dialogs(wdDialogFilePrint).Show

End With

End Sub

Hi Addy,

You need to find out what printer is in use already, and change it back
after. Something like this

Private Sub CMDCOLSPECIAL_Click()
Dim sPrinter as String

With Dialogs(wdDialogFilePrintSetup)
sPrinter = .Printer
.Printer = "\\rother\Canon"
.DoNotSetAsSysDefault = True
.Execute

Dialogs(wdDialogFilePrint).Show

.Printer = sPrinter
.DoNotSetAsSysDefault = True
.Execute

End With

End Sub


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
A

Addy

Many thanks. I did think of that but the only problem is that we have 2 laser
printers in our dpt running on this macro. I did try way back changing the
printer to the canon printer then changing it back wtih the code below

ActivePrinter = "\\rother\lex1340"
Else
ActivePrinter = "\\rother\lex1435"

but it only defaulted to LEX1340 or nothing if that printer wasn't
installed. Any other ideas

cheers
 
A

Addy

Many thanks. I did think of that but the only problem is that we have 2 laser
printers in our dpt running on this macro. I did try way back changing the
printer to the canon printer then changing it back with the code below

ActivePrinter = "\\rother\lex1340"
Else
ActivePrinter = "\\rother\lex1435"

but it only defaulted to LEX1340 or nothing if that printer wasn't
installed. Any other ideas please?

cheers
 
G

Graham Mayor

The point of Jonathan's code is that the original printer information is
captured then later restored. It shouldn't matter what the printer was
originally ?

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

Addy

Apologies Jonathan & Graham. I didn't read your code correctly. I've now
pasted it in my macro and it works a dream. Apologies I am a novice and
struggling a bit sometimes.

Once the special macro is used and you print duplex, staple, holepunch etc
do you know if there's a code to set the printer back to default? I don't
think there will be as there are no macros for special printing such as
duplex, staple etc hence the need for a special printing macro which just
takes you to the relevant printer.

Any help is greatly appreciated.

Many thanks
 
J

Jonathan West

Addy said:
Apologies Jonathan & Graham. I didn't read your code correctly. I've now
pasted it in my macro and it works a dream. Apologies I am a novice and
struggling a bit sometimes.

Once the special macro is used and you print duplex, staple, holepunch etc
do you know if there's a code to set the printer back to default? I don't
think there will be as there are no macros for special printing such as
duplex, staple etc hence the need for a special printing macro which just
takes you to the relevant printer.

Any help is greatly appreciated.

Hi Addy

That is trickier. The whole issue of controlling the printer settings
through VBA is rather fraught. It *can* be done, and I have written a series
of articles on the topic.

The starting point for doing this is that for network printers, you *must*
install a local copy of the printer driver on the workstation.

Here are the articles

Controlling the Printer from Word VBA
Part 1: Using VBA to Select the Paper Tray
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=101

Controlling the Printer from Word VBA
Part 2: Using VBA to control Duplex, Color Mode and Print Quality
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116

Controlling the Printer from Word VBA
Part 3: Dealing with Different Paper Sizes
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=132

Controlling the Printer from Word VBA
Part 4: Getting printer driver details
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=183


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
G

Graham Mayor

You can create macros to set the duplex option etc. See if the examples at
http://www.gmayor.com/fax_from_word.htm put you on course.

You could also setup a number of different versions of the printer drivers
with different parameters pre-set if you want and call them as required.
or
You could address the Printer's PCL language directly using Print fields in
the document eg

Sub PrintDuplex()
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, Text:="PRINT 27""&l1S""", PreserveFormatting:=False
End Sub

Will insert a duplex Print field in the document.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

JayM

Graham

I am trying to use the PRINT field in my macro to print duplex. This works
very well unless the document has a header or footer in which case it throws
the header/footer onto another page.

Any help would be appreciated.

I have looked at Jonathan West's articles but i am just confused by the
whole thing. - That's the problem with being a novice
 
G

Graham Mayor

As you have found, print fields work OK if there is no conflict with the
complexity of the document and I don't have access to a duplexing printer to
test your methodology. However print fields go in the document, not in
macros. The macro I quoted is merely to simplify the insertion of such a
field.

In the circumstances my suggestion to create a duplicate printer driver with
the duplex option set and use the method suggested in the previously posted
link http://www.gmayor.com/fax_from_word.htm to switch printers would be the
least problematic solution.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
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