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