http://www.perlmonks.org?node_id=1006274


in reply to Re^4: Win32::OLE called by subroutine only workes once
in thread Win32::OLE called by subroutine only workes once

I've found Excel OLE to be quirky like this. My pseudo subclass suddenly stopped working due to this error, I found it was because the order of operations had changed. I made sure the following global operations happened before any book level or worksheet level op. happened.
my $ex = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); if (not defined $ex) { die "couldn't get an instance of Excel"; } $ex->{DisplayAlerts}=0; $ex->{SheetsInNewWorkbook} = 1; $ex->{Visible} = 0 ; $Win32::OLE::Warn = 3; # Die on Errors.