Q

Tell Excel or Word to select a printer before printing

This has more to do with the integration between VBA and Lotus Script. How do you tell Excel or Word to select a printer before printing? If this cannot be done, then what about how do I call up a 'Print Preview' instead?

I'll try to give you as much info as I can, since this might be useful in general, as well, to others:

The Print verb is a reserved word in OLE, so it can't be directly called, normally. Several applications (such as WordPro) have created "alternative" methods you can call in its place. These verbs, whichever they are, usually only tell the host application to print (with or without displaying the dialog box).

WordPro:
To Change the Printer Name property:
'This example script sets the current document's printer to the HP LaserJet
	'4L, printing to LPT1:.

	.ActiveDocument.PrintManager.PrintDestination = "LPT1:"
	.ActiveDocument.PrintManager.PrinterName = "HP LaserJet 4L"
	.ActiveDocument.PrintManager.UseDefaultPrinter = True
	.ActiveDocument.PrintManager.UpdatePrinterBins
	.ActiveDocument.PrintManager.GetDefaultPageSize
	.ActiveDocument.PrintManager.UpdatePrinterChanges
	.ActiveDocument.PrintOut([From,][To,][Copies,][nodialog])
Microsoft Word:
. .ActiveDocument.PrintOut(Background, Append, Range, OutputFileName, From, To, Item,Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX, ManualDuplexPrint)
	'To select the active printer...
	ActivePrinter = "HP LaserJet IIISi on \printerslaser"
	This example makes a local HP LaserJet 4 printer on LPT1 the active printer. 
	ActivePrinter = "HP LaserJet 4 local on LPT1:"

	'To get a print preview from Word:
	.ActiveDocument.PrintPreview
Microsoft Excel:
As you'd expect, the commands are similar (exactly the same except for the parameters in this case) between Excel and Word:
	ActivePrinter
	.PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate)
	PrintPreview
Lotus 123:
	Much like WordPro, but 123 has a lot more options.  Here's the basics:

	Print:
		Application.PrintOut

	Preview:
		Application.Preview

	Printer Name:
		Application.PrinterName

Hope this helps!


This was first published in April 2002

Dig deeper on LotusScript

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close