If you look at the examples in Win32::OLE::Const, you'll see that your use statement needs to be more like:

use Win32::OLE::Const ('Microsoft Excel 8.0 Object Library');

Of course, the problem with that is that your code is now expecting only one version of Excel. The '8.0' would need to be changed to support another version of Excel. One way around this that I have done is to use the following line instead:

use Win32::OLE::Const "Microsoft Excel .* Object Library";

This will load the Excel object library for whichever version of Excel is installed - and will hit issues if Excel is not installed. Just keep in mind that there is a chance that Microsoft may change/add/remove constants between versions of Excel. Also, you might want to keep in mind that other behaviors can change between Excel versions that could seriously impact your code - such saving the spreadsheet, which requires different code for Excel 97 and newer Excel versions.


In reply to Re: Unexpected Excel TypeLib error by dasgar
in thread Unexpected Excel TypeLib error by merrymonk

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.