|
|
| Perl Monk, Perl Meditation | |
| PerlMonks |
Re^2: WIN32, OLE, Excel, and Printingby boblawblah (Scribe) |
| on Aug 20, 2008 at 20:14 UTC ( [id://705605]=note: print w/replies, xml ) | Need Help?? |
|
Thank you for your response Corion. And I wish it were (is it?) that simple.
The dialog doesn't set the defaults for each workbook (report). If I call the dialog for only the first workbook/report, the settings are applied to only that workbook. The remaining workbooks are not affected.
I would love to be able to get the values from the print dialog if anyone knows how to do this. The other issue would be *when/if* i get these values, is passing them to the next workbook/report. I see no functions/properties that allow me to change things like single/double sided, layout type, resolution, etc. The OLE function PrintOut only allows you to set the following properties (Taken from MS Object Browser):
As for the actual loop that prints the reports, see below. As you can see the dialog variable determines whether or not the print dialog will be displayed. Another note that may be important, is that the excel xlDialogPrint object actually prints the active workbook (or doesn't, depending on the user's response) so no call to PrintOut is required. A subsequent call to PrintOut on the same workbook keeps the setting set by xlDialogPrint. A workaround to my problem (which is a path I would rather not go down) is that each report could use the same workbook. So the program would create a workbook, create the first report, prompt the use for the print settings, then delete each worksheet in the book, create the next report, and issue the PrintOut command, and then delete each worksheet, etx.. for all subsequent reports. Reasons I do not want to do this is 1) It exposes the underlying interface to the report modules 2) It relies on the user to interact with underlying interface. The user would have to create the Excel and Workbook objects, and pass them to each report. Besides wanting this to be transparent to the user, if I decide that I don't want to use Excel anymore, and instead write my reports in HTML, old code would break (or would be throwing around OLE objects for no good reason). 3) The seems as though this should be trivial - and *hopefully* the only reason it is not is due to my ignorance of programming Microsoft applications compounded by the idiosyncrasies programming Microsoft applications.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||