Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Win32::OLE called by subroutine only workes once

by Anonymous Monk
on Mar 01, 2012 at 17:35 UTC ( #957275=note: print w/ replies, xml ) Need Help??


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


Comment on Re^5: Win32::OLE called by subroutine only workes once
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://957275]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2015-07-29 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls