Changing to Duplex for a printer

B

Bibble Babble

Hi, I have been trying to figure out for a while how to change a printer to
use Duplex in word, I have got a routine from elsewhere that does it using
the DEVMODE (shiver, that was a lesson in confusion).

I see from the code below that you chan tell word which tray to use in a
macro so I am wondering is there a corresponding setting to use duplex from
vba

Sub MyPrint()
Dim sCurrentPrinter As String
sCurrentPrinter = ActivePrinter
ActivePrinter = "HP LaserJet 4050 Series PS"
With Options
.DefaultTray = "Tray 2"
End With
Application.PrintOut FileName:=""
With Options
.DefaultTray = "Use printer settings"
End With
ActivePrinter = sCurrentPrinter
End Sub

Cheers
 
M

Malcolm Smith

Ah, duplex printing. One of the banes of Office development. I have only
found the following method reliable; nothing else seems to work 100% of
the time on 100% of the sites where I have been.

1. Get the system administrators to duplicate all the printer drivers
(the software printers that the users see).

2. Set the duplicate printer to be exactly the same as the original
printer except to set it as Duplex.

3. Name the printer so that, for example, the name ends in 'Duplex'.

4. In your code, when you want to print to Duplex, do the following
steps:
a. Remember the name of your active printer.
b. If it has 'Duplex' at the end of the name of the current printer then
do nothing.
c. Change to the Duplex printer (the name will be the name of the current
printer with 'Duplex' at the end). Make sure you ignore all errors here.
d. Print.
e. Revert back to the saved Printer.


As I say this is the only way that I can guarantee which will work. I
have done things with registry hacks, DLLs and even waving a dead chicken
in front of the print server. None of these work 100% of the time on 100%
of the sites that I have worked at.

What I have described always works.

- Malc
www.dragondrop.com
 
B

Bibble Babble

Cheers Malcolm, I never even thought about duplicating the printer (nope
can't find any wood around here for the damn trees).

It would have saved days of work playing with DEVMODE and API calls etc
 
M

Malcolm Smith

You are most welcome. And, I can tell you that the API calls don't work
all the time on all printers either! And this is even if you are running
as Administrator...

-Malc
www.ukhorseracing.co.uk
 

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