Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Dear wise PerlMonks

I need your help on the following Perl + Win32::OLE + Excel problem:

I have been working on a project on a Windows 7 system, using StrawberryPerl v 5.014 and Win32::OLE. (Running under Eclipse and EPIC). There, the program runs with no errors.

I am trying to use a second PC running Windows XP SP3, to have the same project developed in parallel. On the new system, I have installed Strawberry Perl v 5.016, and used cpanp to install Win32::OLE. I am using the same script sources in the new system.

It turns out that in the new system, I get Win32::OLE errors once I call Microsoft Excel API's. It pops up once I call:

$xlApp = Win32::OLE->new('Excel.Application');

It emits an entire cascade of Win32::OLE errors, just for that one statement. (see below).

Here are exceprts from my Perl code:

package StatementExcel; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(LoadExcel ProcessPreparedSheet); use strict; use warnings; use Encode; use 5.014; use utf8; use Win32::Console; use autodie; use warnings qw< FATAL utf8 >; use Carp; use Win32::OLE qw(CP_UTF8); use Win32::OLE::Const 'Microsoft Excel'; use Cwd; use Text::CSV::Unicode; use File::BOM qw( :all ); use List::MoreUtils 'first_index'; sub LoadExcel { Win32::OLE->Option(CP => CP_UTF8); # set utf8 encoding binmode(STDOUT, ':unix:utf8'); binmode $DB::OUT, ':unix:utf8' if $DB::OUT; # for the debugger Win32::Console::OutputCP(65001); # Set the console code pa +ge to UTF8 my ($i,$j,$StatementRef); my ($xlApp, $xlBook, $Sheet, $rng, $tbl, $xlFile, $RowRecStart, # line where statement records will start $ColRecStart, # column where statement records will sta +rt $StatementRows, # number of statement rows $HeadingRange, $RecordsRange); my (@Statement, @Heading); my @columns = ('a'..'z'); $Win32::OLE::Warn = 2; my %parms = @_; # ... more code $xlApp = Win32::OLE->new('Excel.Application'); # Start Excel an +d make it visible # ... more code

and here are excerpts from the error dump. Like I said, this entire dump was output just for that single OLE statement:

Win32::OLE(0.1709) error 0x80020009: "Exception occurred" in METHOD/PROPERTYGET "ActiveChart" at D:/MyPrograms/System/Strawb +erryPerl/perl/vendor/lib/Win32/OLE/Lite.pm line 216. ... called at D:/My Documents/Technical/Perl/Eclipse workspace/.metada +ta/.plugins/org.epic.debug/perl5db.pl line 646 DB::eval called at D:/My Documents/Technical/Perl/Eclipse workspac +e/.metadata/.plugins/org.epic.debug/perl5db.pl line 3244 DB::DB called at D:/My Documents/Technical/Perl/Eclipse workspace/ +StatementExcel.pm line 87 StatementExcel::LoadExcel('StatementRef', 'ARRAY(0x1c72e0c)', 'Fil +esRef', 'HASH(0x1c7d80c)', 'Debug', 1, 'XLFileName', 'D:\My Documents +\Technical\Perl\Eclipse workspace\FIBI\Work\FI...', 'OutpStructRef', +...) called at D:/MyPrograms/System/StrawberryPerl/perl/vendor/lib/Wi +n32/OLE/Lite.pm line 216. ... Win32::OLE(0.1709) error 0x80020009: "Exception occurred" in METHOD/PROPERTYGET "Charts" at D:/MyPrograms/System/StrawberryP +erl/perl/vendor/lib/Win32/OLE/Lite.pm line 216. ... DB::eval called at D:/My Documents/Technical/Perl/Eclipse workspac +e/.metadata/.plugins/org.epic.debug/perl5db.pl line 3244 DB::DB called at D:/My Documents/Technical/Perl/Eclipse workspace/ +FIBI/StatementExcel.pm line 87 StatementExcel::LoadExcel('StatementRef', 'ARRAY(0x1c72e0c)', 'Fil +esRef', 'HASH(0x1c7d80c)', 'Debug', 1, 'XLFileName', 'D:\My Documents +\Technical\Perl\Eclipse workspace\FIBI\Work\FI...', 'OutpStructRef', +...) called at D:/My Documents/Technical/Perl/Eclipse workspace/FIBI/ +FIBI Conv.pl line 121 ... Win32::OLE(0.1709) error 0x80020009: "Exception occurred" in METHOD/PROPERTYGET "Excel4IntlMacroSheets" at D:/MyPrograms/Sys +tem/StrawberryPerl/perl/vendor/lib/Win32/OLE/Lite.pm line 216. ... Win32::OLE(0.1709) error 0x80020009: "Exception occurred" in METHOD/PROPERTYGET "Excel4MacroSheets" at D:/MyPrograms/System/ +StrawberryPerl/perl/vendor/lib/Win32/OLE/Lite.pm line 216. eval {...} called at D:/MyPrograms/System/StrawberryPerl/perl/vend +or/lib/Win32/OLE/Lite.pm line 216 Win32::OLE::Tie::FETCH('Win32::OLE::Tie=HASH(0x25ee6ec)', 'Excel4M +acroSheets') called at D:/My Documents/Technical/Perl/Eclipse workspa +ce/.metadata/.plugins/org.epic.debug/dumpvar_epic.pm line 162 ... Win32::OLE(0.1709) error 0x80020009: "Exception occurred" in METHOD/PROPERTYGET "FileFind" at D:/MyPrograms/System/Strawberr +yPerl/perl/vendor/lib/Win32/OLE/Lite.pm line 216. ...

What to do?

Many TIA

Helen


In reply to Win32:OLE errors when running same code on Windows XP by HelenCr

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (17)
    As of 2014-10-24 16:14 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (132 votes), past polls