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


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

I'm writing a script which opens each excel file in a directory, reads some values from the workbook, then closes the workbook, and I had the same problem of Excel quitting when I closed the workbook.

The inspiration came when I noticed the problem did not happen if I manually opened Excel first (with the default, blank "Book1")

The work-around I used was to create a new workbook first, process all the files, (open, close, open, close...) then close my "KeepOpen" workbook when I was all done:

$KeepOpen = $Excel->Workbooks -> Add; # your code / loop here $KeepOpen -> Close;

Hope this helps,
-- zaaj

Replies are listed 'Best First'.
Re^6: Win32::OLE called by subroutine only workes once
by Anonymous Monk on Dec 23, 2016 at 21:13 UTC
    Thank you very much, this worked for me!