I'm sorry to have to write in with such a seemingly simple problem, but like a tree I'm stumped!
This script takes in an excel file location, splits it up by the slashes, puts the file name backto gether with the slashes the other way round, and doubles the amount of slashes, ergo C:/hello/Perl/People.xls becomes C:\\hello\\Perl\\People.xls, This is so the Win32 OLE module will read the file. I have managed to convert the file location like said, and can print out an example of it, but when I try and use the variable to open the excel file, it's looking for the file with a \ Missing, hmmm Curious.
--CODE--
@tempsplit = split(/\//, $excelFile);
$nameConcat = "";
$flag = 1;
foreach $name (@tempsplit){
if($flag == 1){
$nameConcat = "$nameConcat"."$name";
$flag = 0;
}else{
$nameConcat = "$nameConcat"."\\\\"."$name";
}
}
print "Excel name : $nameConcat\n";
$Book = $Excel->Workbooks->Open("$nameConcat"
; # open Excel file
# my $Book = $Excel->Workbooks->Open("R:\\engbodan\\asmit386\\perlStuff\\AimsAutomation\\teachMe\\Tester.xls"
; # open Excel file
$Sheet = $Book->Worksheets(1); # select worksheet number 1
$array = $Sheet->Range("A8:B9"
->{'Value'}; # get the contents
$Book->Close;
----
--Results--
Excel name : R:\\engbodan\\asmit386\\perlStuff\\AimsAutomation\\Tester\\Excel\\t
est.xls
Tk::Error: OLE exception from "Microsoft Excel":
'R:\\engbodan\\asmit386\\perlStuff\\AimsAutomation\\Tester\\Excel\test.xls'
could not be found. Check the spelling of the file name, and verify that the
file location is correct.
----
Thanks for any help.
This script takes in an excel file location, splits it up by the slashes, puts the file name backto gether with the slashes the other way round, and doubles the amount of slashes, ergo C:/hello/Perl/People.xls becomes C:\\hello\\Perl\\People.xls, This is so the Win32 OLE module will read the file. I have managed to convert the file location like said, and can print out an example of it, but when I try and use the variable to open the excel file, it's looking for the file with a \ Missing, hmmm Curious.
--CODE--
@tempsplit = split(/\//, $excelFile);
$nameConcat = "";
$flag = 1;
foreach $name (@tempsplit){
if($flag == 1){
$nameConcat = "$nameConcat"."$name";
$flag = 0;
}else{
$nameConcat = "$nameConcat"."\\\\"."$name";
}
}
print "Excel name : $nameConcat\n";
$Book = $Excel->Workbooks->Open("$nameConcat"
# my $Book = $Excel->Workbooks->Open("R:\\engbodan\\asmit386\\perlStuff\\AimsAutomation\\teachMe\\Tester.xls"
$Sheet = $Book->Worksheets(1); # select worksheet number 1
$array = $Sheet->Range("A8:B9"
$Book->Close;
----
--Results--
Excel name : R:\\engbodan\\asmit386\\perlStuff\\AimsAutomation\\Tester\\Excel\\t
est.xls
Tk::Error: OLE exception from "Microsoft Excel":
'R:\\engbodan\\asmit386\\perlStuff\\AimsAutomation\\Tester\\Excel\test.xls'
could not be found. Check the spelling of the file name, and verify that the
file location is correct.
----
Thanks for any help.