in reply to Selecting printer in Excel

I think that you want something like this:
my $pobj = $excel_obj->ActivePrinter; if ($pobj) { print ("Name of default printer => $pobj \n"); }
You can find a complete example here.

Replies are listed 'Best First'.
Re^2: Selecting printer in Excel
by merrymonk (Hermit) on Jan 14, 2011 at 10:56 UTC
    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