Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print macro

Status
Not open for further replies.

NNNNN

MIS
Dec 2, 2002
90
0
0
GB
The macro below is designed to print a document, first page headed, subsequent pages on quality plain and also print the whole document again on copy paper

Part 1 works fine on its own
Part 2 works fine on its own
BUT together the tray selection does not work

What happens is that sure enough page 1 is printed on headed but everything else
Is printed on copy paper so it looks like the command “.OtherPagesTray = 259 ' quality plain paper
” is ignored or overwritten by “OtherPagesTray = 261 ' thin copy paper”

It appears that the printing is done after all the VB is processed and not stage 1 followed by stage 2


Sub prnt()

' **** part 1 print a document first page headed paper, other pages on plain paper
With ActiveDocument.PageSetup
.FirstPageTray = 260 ' headed paper
.OtherPagesTray = 259 ' quality plain paper
End With

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

'*** part 2 print a copy of the document on copy paper
With ActiveDocument.PageSetup
.FirstPageTray = 261 ' thin copy paper
.OtherPagesTray = 261 ' thin copy paper
End With

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

End Sub

Is there a way to process part one print then move on to stage 2
Or is there a much better way of tackling this problem?

Thanks in advance
 

I have three suggestions that might be of help:

1) Change "Application.Printout" to "ActiveDocument.Printout"
2) Split this into two subroutines (such as Prnt1 and Prnt2)
3) Have the last command in Prnt1 call Prnt2

The second two may not be needed if you make the first change and do a test run; VBA can be very picky about command structure and all my references use the document vs the application format. This seems ridiculous on its face since these both work as stand-alone routines, but I have seen stranger things happen with VBA code - some of which no one has ever been able to explain. In any event this won't take long to run as a test, so there is very little to lose.

[glasses]

----------------------------------------------------------------------------------
"A committee is a life form with six or more legs and no brain." -- L. Long
 
Hi

Thanks for your help
Unfortunately, it made no difference, however I introduced Options.PrintBackground
This made a little difference but only if I use a message box between part1 and part 2
without Options.PrintBackground = False the message box makes no difference

I do not want to use the message box so is there any other way

Thanks
 
Try to capture what the value is of the otherpagestray before printing.


msgbox activedocument.pagesetup.otherpagestray

Place this right above the 2nd printout and see what the value is!


ck1999
 
I would do as WalkerEvans suggests. make them two separate procedures and call the second at the end of the first. If you do not want to do that (but I think it would be a good idea), you may also want to consider having it Wait a little between the instructions.

faq219-2884

Gerry
My paintings and sculpture
 
I have a notion that .PrintOut(Background:=false) should be set, because:
the printer might still be processing the first job with VBA already pressing the second job in the printer's memory; maybe the printer's tray persists until printing of a job is really finished.
M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top