R
Richard S Beckett
Guys,
I ahve written a script that runs in a DOS window, and parses a log file
into Excel.
If a user decides to terminate the script whilst running, the Excel process
gets left running, and messes up the operation of the script, and Excel
afterwards.
I invoke Excel like this:
my $excel;
eval {$excel = Win32::OLE->GetActiveObject('Excel.Application')};
die "WARNING! Excel not installed" if $@;
unless (defined $excel) {
$excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die
"ERROR, cannot start Excel";
}
I have an END block that closes Excel down, and I have successfully trapped
Control C so that the END block gets executed and Excel is closed properly.
However, I have found that if the user presses the X button on the window,
then I am again left with an orphan Excel process.
Should I start Excel differently so that it terminates when the script does?
Alternatively, can anyone give me any pointers on how to trap the user
clicking on the X so that I can ensure that my END block is run, like I now
do for control C?
Thanks.
I ahve written a script that runs in a DOS window, and parses a log file
into Excel.
If a user decides to terminate the script whilst running, the Excel process
gets left running, and messes up the operation of the script, and Excel
afterwards.
I invoke Excel like this:
my $excel;
eval {$excel = Win32::OLE->GetActiveObject('Excel.Application')};
die "WARNING! Excel not installed" if $@;
unless (defined $excel) {
$excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die
"ERROR, cannot start Excel";
}
I have an END block that closes Excel down, and I have successfully trapped
Control C so that the END block gets executed and Excel is closed properly.
However, I have found that if the user presses the X button on the window,
then I am again left with an orphan Excel process.
Should I start Excel differently so that it terminates when the script does?
Alternatively, can anyone give me any pointers on how to trap the user
clicking on the X so that I can ensure that my END block is run, like I now
do for control C?
Thanks.