I have been working on a project on a Windows 7 system, using StrawberryPerl v 5.014 and Win32::OLE.
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 and Win32::OLE::Const.
I am using the same script sources in the new system.
It turns out that in the new system, somehow
use Win32::OLE::Const 'Microsoft Excel';
is not having an effect. I am getting the error:
Bareword "xlExcel8" not allowed while "strict subs" in use in StatementExcel.pm line 159.
This error does not show up in the first, original system I mentioned.
What to do?
TIA, Helen
Here's some excerpts from the program:
package StatementExcel;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(LoadExcel ProcessPreparedSheet);
use strict;
use warnings;
use Encode;
use 5.016;
use utf8;
use Win32::Console;
use autodie;
use warnings qw< FATAL utf8 >;
use StateConversion;
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';
...
$xlBook -> SaveAs( $xlFile, xlExcel8);
$i = Win32::OLE->LastError();
if ($i) {
PrintT $parms{LogStructRef}{HANDLE}, "Error trying to save Excel file:\n", $i;
} # end if ($i)
PrintT $parms{LogStructRef}{HANDLE}, 'Press <return> to continue...'; # Wait for user input...
$j = <STDIN>;
# Clean up
$xlBook->{Saved} = 1;
$xlApp->Quit;
$xlBook = 0;
$xlApp = 0;
...
Note: cross-posted on PerlMonks: http://www.perlmonks.org/?node_id=985596