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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
For example, maybe XlExcel8 is defined for Excel 2010 (which is installed on the original system), and has a different name in Excel 2003 (installed on the Windows XP system)?

Somehow I totally overlooked that the error message in your original post was complaining about "xlExcel8". Combined with the fact that you're using Excel 2010 and Excel 2003, I think I know what's going on. The problem is not with the use Win32::OLE::Const 'Microsoft Excel'; line at all.

Starting with Excel 2007, Microsoft introduced a new Excel file format and used .xlsx file extension as the default file extension for the new file format. Also, with Excel 2007 and Excel 2010, the default file type when saving a file is the new file type. The user can still choose the older file type if he/she wants to.

Since you're not providing much code, I have to make some guesses. I'm assuming that you've developed your code on your system with Excel 2010 and wanted to save in the older Excel file format. In that case, you have to specify the file format when saving the file. That's where you're using the xlExcel8 constant. However, that's not a defined constant in the Excel 2003 OLE library. Although there is a free update to Excel 2003 that allows it to use the new file format, I can't say for sure if that will add the xlExcel8 constant to the Excel 2003 OLE library.

If you're planning to have a script that works with Excel versions 2003, 2007 and 2010, then you'll probably need to check to see what version of Excel is installed in order to know which save methods to call. The way that I've done that before was to look at the code from the OLE browser from the Win32::OLE module to see how it dynamically pulled out information about the available OLE libraries. Then I wrote a subroutine that looked for the "Microsoft Excel X.0 Object Library" and used the X value to determine the Excel version. Excel 2010 is 14, Excel 2007 is 12, and I believe that Excel 2003 is 8.

Here's how to do a quick test of my assumptions. If my assumptions are correct, you probably have something like the following in your code:

$book->SaveAs({Filename => $filename, FileFormat => xlExcel8});

On your Excel 2003 system, try changing that line to the following:

$book->SaveAs({Filename => $filename});

If I'm right, that should work on your system running Excel 2003.


In reply to Re^3: "use Win32::OLE::Const" not having an effect by dasgar
in thread "use Win32::OLE::Const" not having an effect by HelenCr

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found