If I use this subroutine once everything is fine, but if I do it twice the following error occures: Win32::OLE(0.1709) error 0x80010108: "Das aufgerufene Objekt wurde von den Clients getrennt" in METHOD/PROPERTYGET "Application" at Helper.pm line 233 Can't use an undefined value as a HASH reference at Helper.pm line 233. I call it like this:sub OpenAndSaveXLS{ (my $xlsfile)=@_; if((-e $xlsfile) and (!isFileInUse($xlsfile))){ $xlsfile =~ s/\//\\/g; print "xls: ".$xlsfile . "\n\n"; my $ex_ol = Win32::OLE::Const->Load("Microsoft Excel 12.0 Obje +ct Library"); my $Excel = Win32::OLE->GetActiveObject('Excel.Application')|| + Win32::OLE->new('Excel.Application', 'Quit'); $Excel->Application->{DisplayAlerts} = 0; my $book = $Excel->Workbooks->Open("$xlsfile"); $Excel->ActiveWorkbook->SaveAs({FileName=>"$xlsfile", FileForm +at=>$$ex_ol{'xlWorkbookNormal'}}); $book->Close(); $Excel->Quit(); return 0; } }
If I do it in debugging-mode, everything works fine. Obviously the first OpenAndSaveXLS-call is not finished when the 2nd starts.Helper::OpenAndSaveXLS("D:/foo.xls"); Helper::OpenAndSaveXLS("D:/foo2.xls");
In reply to Win32::OLE called by subroutine only workes once by fish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |