Perl OLE document visible

189 Views Asked by At

I try to open and modify an Excel document with a Perl script, and I want this document to be still open after. I use the following code :

unless (defined $ex) {
$ex = Win32::OLE->new('Excel.Application', sub{$_[0]->Quit;})
or die "Cannot start Excel";
}

$ex->{Visible} = 1;

The Excel document briefly appears, then vanishes. The work is correctly done, but Excel closes down after. Is there a way to keep Excel open?

1

There are 1 best solutions below

1
On

Just remove your destructor construct from the new method:

$ex = Win32::OLE->new('Excel.Application')
or die "Cannot start Excel";