$excel->{ActivePrinter} = "Auto HP Deskjet 6500 Series on HOMEDELLTOWER on Ne02:"; #### use strict ; use OLE; use Win32::OLE::Const "Microsoft Excel"; my ($excel, $workbook, $sheet, $jex); $excel = CreateObject OLE "Excel.Application"; $workbook = $excel -> Workbooks -> Add; print "before jex loop\n"; foreach $jex (sort {$a cmp $b} %$excel) { print "$jex <$excel->{$jex}\n"; } print "after jex loop\n";