deshaw
asked on
Win32::OLE(0.1702) error 0x800706be: "The remote procedure call failed"
I am writing a small perl code for opeining two excel files simultaneously. When I ran the script it's opening the first file successfully and when it came to open second file. it's throwing the above mentioned error.
#use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3;
sub getdata;
$path1 = "C:\\edu\\Test.xls"; #first file
$pointer = &getdata($path1);
foreach $value1 (@$pointer) {
foreach $value2 (@$value1){
print $value2;
print "\n";
}
}
$path2 = "c:\\edu\\Test2.xls"; #second file
$pointer1 = &getdata($path2);
foreach $value3 (@$pointer1) {
foreach $value4 (@$pointer2) {
print $value4;
}
}
sub getdata {
my ($path) = @_;
# get already active Excel
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application','quit'); # application or open new
my $Book = $Excel->Workbooks->Open($path); # open Excel file
my $Sheet = $Book->Worksheets(1); # select worksheet number 1
my $array = $Sheet->Range("A1:B2")->{'Value'}; # get the contents
$Book->Close;
return ($array);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
One more question. Where can we find more information about what win32::OLE is exactly doing and how it is querying information.
deshaw,
I do not know much more than what is written up in its man page http://search.cpan.org/~jdb/Win32-OLE-0.1709/lib/Win32/OLE.pm, sorry. It is using Microsoft's OLE extensions - perhaps other experts can help or search the www.
lwadwell
I do not know much more than what is written up in its man page http://search.cpan.org/~jdb/Win32-OLE-0.1709/lib/Win32/OLE.pm, sorry. It is using Microsoft's OLE extensions - perhaps other experts can help or search the www.
lwadwell
When you use Win32::OLE like this, you are calling actual Excel functions. You can look at the Excel help for details on what the functions do in Excel.
ASKER