in reply to Re^3: MS Excel 2007 never dies - or at least the process wont
in thread MS Excel 2007 never dies - or at least the process wont
I've narrowed the sample code down to a more minimally functional set. With any old .xlsx file in the existing work directory, this should demonstrate the conditions of problem I'm experiencing without going more indepth into the code.
This script - in the environment in question - leaves behind a stray process named "EXCEL.EXE" in task manager.
From what I have been able to glean from the documentation I've seen - the destructor is defined here new('Excel.Application','Quit')
use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); use FindBin qw($Bin); $Win32::OLE::Warn = 3; my $Excel = Win32::OLE->new('Excel.Application','Quit'); my $curpath = "$Bin/"; undef my $j; for $j (0 .. length($curpath)){ if(substr($curpath,$j,1)eq '/'){substr($curpath,$j,1) = '\\';} } undef my $listfile; $listfile = "filelist.txt"; my $syscmd = "dir \/b *.xlsx > ".$listfile; system($syscmd); close(STDERR); open(STDERR, ">load_error_log.txt"); open(RDR0, $listfile); undef my $listread; while ($listread = <RDR0>){ chomp($listread); my $ExcelFile = $curpath.$listread; print "*Loading $ExcelFile*\n"; my $Book = $Excel->Workbooks->Open($ExcelFile) || die("Unable to o +pen $ExcelFile ", Win32::OLE->LastError()); $Book->Close(0); undef $Book; } $Excel->Quit(); undef $Excel; close (RDR0); close (STDERR);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: MS Excel 2007 never dies - or at least the process wont
by davies (Monsignor) on Aug 25, 2011 at 18:28 UTC | |
by otism (Initiate) on Aug 25, 2011 at 22:24 UTC |