use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
my $Excel1 = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit'); # get already active Excel
#$Excel->{Visible} = 1;
print "file 1: ";
my $file1 = <STDIN>;
chomp($file1);
# application or open new
print "start of the column standard_address: ";
my $cs1 = <STDIN>;
print "end of the column standard_address: ";
my $ce1 = <STDIN>;
print "start of the column 'city': ";
my $city1 = <STDIN>;
print "end of the column 'city': ";
my $city2 = <STDIN>;
print "start of the column 'county': ";
my $cy1 = <STDIN>;
print "end of the column 'county': ";
my $cy2 = <STDIN>;
my $Book1 = $Excel1->Workbooks->Open($file1); # open Excel file
my $Sheet1 = $Book1->Worksheets(1); # select worksheet number 1
my $array1 = $Sheet1->Range("$cs1:$ce1")->{'Value'}; # get the contents
my $array11= $Sheet1->Range("$city1:$city2")->{'Value'};
my $array12= $Sheet1->Range("$cy1:$cy2")->{'Value'};
$Book1->Close;
The filename is to be entered dynamically when the code is running. After entering the filename which is stored in the same folder as the code I am getting an error:
OLE exception from "Microsoft Office Excel":
'Database.xls' could not be found. Check the spelling of the file name, and
verify that the file location is correct.
If you are trying to open the file from your list of most recently used
files, make sure that the file has not been renamed, moved, or deleted.
Win32::OLE(0.1709) error 0x800a03ec
in METHOD/PROPERTYGET "Open" at final2.pl line 36
Please help me. The file is stored with the correct name in the same folder.
Thanks
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
my $Excel1 = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit'); # get already active Excel
#$Excel->{Visible} = 1;
print "file 1: ";
my $file1 = <STDIN>;
chomp($file1);
# application or open new
print "start of the column standard_address: ";
my $cs1 = <STDIN>;
print "end of the column standard_address: ";
my $ce1 = <STDIN>;
print "start of the column 'city': ";
my $city1 = <STDIN>;
print "end of the column 'city': ";
my $city2 = <STDIN>;
print "start of the column 'county': ";
my $cy1 = <STDIN>;
print "end of the column 'county': ";
my $cy2 = <STDIN>;
my $Book1 = $Excel1->Workbooks->Open($file1); # open Excel file
my $Sheet1 = $Book1->Worksheets(1); # select worksheet number 1
my $array1 = $Sheet1->Range("$cs1:$ce1")->{'Value'}; # get the contents
my $array11= $Sheet1->Range("$city1:$city2")->{'Value'};
my $array12= $Sheet1->Range("$cy1:$cy2")->{'Value'};
$Book1->Close;
The filename is to be entered dynamically when the code is running. After entering the filename which is stored in the same folder as the code I am getting an error:
OLE exception from "Microsoft Office Excel":
'Database.xls' could not be found. Check the spelling of the file name, and
verify that the file location is correct.
If you are trying to open the file from your list of most recently used
files, make sure that the file has not been renamed, moved, or deleted.
Win32::OLE(0.1709) error 0x800a03ec
in METHOD/PROPERTYGET "Open" at final2.pl line 36
Please help me. The file is stored with the correct name in the same folder.
Thanks