Duplex Printing

J

JayM

I know this has probably been asked many times before but I am a bit of a
simpleton when it comes to this duplex printing lark. I have looked at
Jonathan West's articles on controlling a printer but frankly I am a bit lost
with it all.

I have created some macros that print to different paper trays for our
printers. Mostly HP PCL 5e/6 drivers the macros I am using work for all the
different printer types we have at the moment 4000 - 4100.

What I would like to be able to do is to set some macros to print duplex as
well.

My current macro looks something like this :

Sub PRINT_THIN_P()
' PRINT_THIN_P Macro
UNPROTECTDOCUMENT
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterPaperCassette
.OtherPagesTray = wdPrinterPaperCassette
End With
Application.PrintOut filename:="", Range:=wdPrintAllDocument,
Item:=wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False
REPROTECTDOCUMENT
End Sub

The UNPROTECT/REPROTECTDOCUMENT just checks to see if it is a protected form
and unlocks it for printing and then protects it again after printing.
(Thanks to help from DebsP)

How can I add duplex printing to this. I suppose I should explain that this
is for some 100+ users over three sites using different printers.

If you need any more info from me please shout. I would be everso grateful
for any help on this matter.
 
J

Jonathan West

Hi jay,


JayM said:
I know this has probably been asked many times before but I am a bit of a
simpleton when it comes to this duplex printing lark. I have looked at
Jonathan West's articles on controlling a printer but frankly I am a bit
lost
with it all.

I have created some macros that print to different paper trays for our
printers. Mostly HP PCL 5e/6 drivers the macros I am using work for all
the
different printer types we have at the moment 4000 - 4100.

What I would like to be able to do is to set some macros to print duplex
as
well.

You need to look at this article

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

You need to paste the whole of the code near the bottom of the article, in
the "Main code for the article" into a separate module in your template.
My current macro looks something like this :

Sub PRINT_THIN_P()
' PRINT_THIN_P Macro
UNPROTECTDOCUMENT
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterPaperCassette
.OtherPagesTray = wdPrinterPaperCassette
End With
Application.PrintOut filename:="", Range:=wdPrintAllDocument,
Item:=wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, Collate:=True, Background:=True,
PrintToFile:=False
REPROTECTDOCUMENT
End Sub

Then you change your macro as follows

Sub PRINT_THIN_P()
' PRINT_THIN_P Macro
UNPROTECT

Dim iDuplex As Long

iDuplex = GetDuplex 'save the current setting

With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterPaperCassette
.OtherPagesTray = wdPrinterPaperCassette
End With

SetDuplex 3 'set for booklet printing

Application.PrintOut filename:="", Range:=wdPrintAllDocument, _
Item:=wdPrintDocumentContent, Copies:=1, Pages:="", _
PageType:=wdPrintAllPages, Collate:=True, _
Background:=True, PrintToFile:=False

SetDuplex iDuplex 'restore the original setting

REPROTECTDOCUMENT
End Sub

Dim iDuplex As Long

iDuplex = GetDuplex 'save the current setting
SetDuplex 3 'set for vertical binding
ActiveDocument.PrintOut Background:=False
SetDuplex iDuplex 'restore the original setting
The UNPROTECT/REPROTECTDOCUMENT just checks to see if it is a protected
form
and unlocks it for printing and then protects it again after printing.
(Thanks to help from DebsP)

How can I add duplex printing to this. I suppose I should explain that
this
is for some 100+ users over three sites using different printers.

In that case your page setup commands may not be adequate for the purpose -
the Word constants bear not the slightest relationship to the Tray IDs used
by different models of printer. You may need to change the values assigned
depending on which printer is in use. Take a look at this article to find
out how to obtain the actual tray IDs for any particular printer

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


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

JayM

Jonathan

Many thanks for your help with this. It is so easy when you know how!!!

Just one more question however, I have this working lovely for my HP
Laserjet printers but we have a couple of sharp printer/copiers on which the
duplex code doesn't seem to work.

Do you know of any reason for this? I will double check my code to make
sure I have typed it correctly.

Again many thanks for your help
 
J

JayM

Jonathan

Just another thought. Is it possible to rotate the paper. I have one
document that needs to be printed on letterheaded paper and duplex but to get
it up the right way on the paper you have to tell the HP printer to rotate it.

JayM
 
J

Jonathan West

JayM said:
Jonathan

Just another thought. Is it possible to rotate the paper. I have one
document that needs to be printed on letterheaded paper and duplex but to
get
it up the right way on the paper you have to tell the HP printer to rotate
it.


You can choose horizontal binding (tablet layout) or vertical binding
(booklet layout)

SetDuplex 2 sets horizontal binding. Try that


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

Jonathan West

JayM said:
Jonathan

Many thanks for your help with this. It is so easy when you know how!!!

Just one more question however, I have this working lovely for my HP
Laserjet printers but we have a couple of sharp printer/copiers on which
the
duplex code doesn't seem to work.

Do you know of any reason for this? I will double check my code to make
sure I have typed it correctly.

The article mentions that controlling printers is one of the most iffy parts
of VBA programming, because of the wide variety of printers out there and
the wide variety of quality in the printer driver code.

Two possible causes to this.

1. The Sharp printers are networked and you haven't installed a local copy
of the printer driver. Install the driver locally if this is so.

2. The printer drivers are out of date or otherwise generally poor. You
might find that there is an updated driver available on the web.

If neither of these sorts the problem, then all I can suggest is you contact
Sharp, point them to the article, and ask why their printer drivers don't
work right.


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

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