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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Automation - best way to select printer tray? 1

Status
Not open for further replies.

kazl

Programmer
Dec 9, 2002
68
GB
Hello Tek-Tips Users

I am batch printing documents from VFP6 using Word and need to be able to specify the printer tray at the start.

These documents are built up from alternate files using a normal page, then a page of terms for duplex printing....

This works very well until I try using the constants for the paper tray with PageSetup. The odd and even pages are completely different but the column layouts get rearranged and spoil the layout.

I used GETPRINTER() and then oWord.ActivePrinter to select the printer for the batch. Is there a way to specify the tray for this printer instead of using PageSetup?

I believe that only way to control how documents duplex is by having the printer set up twice, so we can select either the Duplex printer or Not Duplex before the print run.

Will I have to resort to this approach for selecting printer trays? (This is only for Duplex docs, so I could have Duplex Plain tray 2 and Duplex Letterheads tray 3)

Any ideas anyone, please?

Kaz

 

?SYS(1037)

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Mike.

Doesn't quite do what I need because I can't rely on users to select the right tray.

It's a shame I couldn't get it right in Word without wrecking the alternate page layouts.

But, I'll simplify things so that VFP Word duplex printing is all bottom tray and Word, Excel, etc is all default printer and top tray. Not a problem. Another day done. Nevermind. Hey ho..

Thanks anyway. Kaz
 
Kaz,

Setting up two printer drivers -- each one defaulting to a different paper tray -- seems to me to be the easiest way of doing this. As you've pointed out, SYS(1037) won't work for you because it relies on user interaction. I don't think you can do it via Automation to Word because Word doesn't know anything about paper trays - it's all controlled within the printer driver.

The only other possibility that comes to mind is to directly call the printer driver's API, but setting up two drivers would be vastly simpler.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hi Mike

Thanks for your response.

This is the simplest and probably the most reliable method, which all sounds good to me.

Cheers.

Kaz
 
It appears that it is possible to automate this. Based on documentation on MSDN and a page of word constants out on the foxwiki I came up with the following:
Code:
*!* For a list of Word constants either drag-n-drop from the
*!* Object Browser or in this case you can visit
*!* [URL unfurl="true"]http://fox.wikis.com/wc.dll?Wiki~WordConstants~VFP[/URL]

#DEFINE wdPrinterDefaultBin  0
#DEFINE wdPrinterUpperBin  1
#DEFINE wdPrinterLowerBin  2
#DEFINE wdPrinterMiddleBin  3

LOCAL lnFirstSettingPrevious, lnOtherSettingPrevious, loWordApp, loDoc

loWordApp = CREATEOBJECT("word.application")
loDoc = loWordApp.Documents.OPEN("C:\MyDocument.doc", .F., .F., .F.)

WITH loDoc
	.REPAGINATE()

	*!* Save the previous settings
	lnFirstSettingPrevious = .PageSetup.FirstPageTray
	lnOtherSettingPrevious = .PageSetup.OtherPagesTray

	.PageSetup.FirstPageTray = wdPrinterLowerBin
	.PageSetup.OtherPagesTray = wdPrinterLowerBin

	.PRINTOUT()

	*!* restore previous settings
	.PageSetup.FirstPageTray = lnFirstSettingPrevious
	.PageSetup.OtherPagesTray = lnOtherSettingPrevious

	.CLOSE()
ENDWITH

loWordApp.QUIT()

boyd.gif

 
Hi Craig

You are right. With these constants you can select the paper tray before and after printing the document.

My only problem is that the alternate pages have different page setup and column widths. So I would have needed to apply the paper tray changes to each page somehow and it got a bit messy.

This code is useful for normal documents though.

Kaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top