Thank you for both replies – they have let me do what I want
The test Perl is below
use strict ;
use OLE;
use Win32::OLE::Const "Microsoft Excel";
my ($excel, $workbook, $sheet, $file_name, $pobj);
$file_name = "C:\\Bookxxx.xls";
$excel = CreateObject OLE "Excel.Application";
$workbook = $excel -> Workbooks -> Open($file_name);
$pobj = $excel->ActivePrinter;
if ($pobj) {
print "start - Name of default printer => $pobj \n";
}
$excel->{ActivePrinter} = "Auto HP Deskjet 6500 Series on HOMEDELLTOWE
+R on Ne02:";
$pobj = $excel->ActivePrinter;
if ($pobj) {
print "after setting - Name of default printer => $pobj \n";
}
$workbook->PrintOut();
Typical output from an MSDOS screen is
C:\\test-exprinter.pl
start - Name of default printer => deskPDF on DDM:
after setting - Name of default printer => Auto HP Deskjet 6500 Series on HOMEDELLTOWER on Ne02:
The process is that
1. You set the default printer to the one you want to use
2. Use the Perl
3. Use the output to get the name of the printer
4. Set the default printer to what it should be
5. Add the found printer name into the Perl code
You should then be able to choose the printer you want to use
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.