Unless you're doing something that needs the memory after your $book->Close, I would advise replacing your four lines

$book->Close; Win32::OLE->Uninitialize; undef $book; undef $ex;

with $ex->Quit. I've never encountered the "Uninitialize" method and don't know what it does. But quitting Excel will close the book automatically, while your objects will automatically be undefined when the Perl programme exits.

I think that will solve your problem. Two more tips, though. If you add use Win32::OLE::Const 'Microsoft Excel'; to your use statements, you will get xlVisible, xlMinimised and all the rest.

I've never seen the sub {$_[0]->Quit;} construct before. I've seen things very like it, but I've never used them myself as I've never run into situations where they have seemed necessary. It's unlikely to cause a problem if you know why it's there, but unless it solves a problem (and you're dying on the same line, which should cope), you might prefer to take it out.

Regards,

John Davies


In reply to Re: Excel process created with Win32::OLE doesn't quit when expected by davies
in thread Excel process created with Win32::OLE doesn't quit when expected by ArtYaffe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.