dear Michael,
can u please let me know the possibel errors in my code.
Error i got is :
Can't call method " Range" on an undefined range at line .
code:
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
# uses the already open Excel application or opens one
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;});
# makes Excel visible
$Excel->{Visible} = 1;
my $Sheet = $Excel->Workbooks->Open("C:\\Temp\\test.xls!sheet1");
# fetches the values in the range A8:B9
my $array = $Sheet->Range("A10:B10")->{'Value'};
print "Values in the range A10:B10 are:\n";
foreach my $ref_array (@$array) {
foreach my $scalar (@$ref_array) {
print "$scalar\t";
}
print "\n";
}
# then saves the workbook
$Book->Save();
Have an ineffable day.
With regards & Thanks
Pons.
Extn: 1328
--------------------------------------------------------------------------------
Learn to Grow ------> Grow to Learn more & more.
--------------------------------------------------------------------------------
Henning Michael Møller-Nielsen
<[EMAIL PROTECTED]> To:
[EMAIL PROTECTED],
Sent by:
[EMAIL PROTECTED]
[EMAIL PROTECTED] cc:
eState.com Subject: Re: OLE
Extension VERY urgent.
please
02/21/01 11:26 AM
At 08:28 21-02-2001 +0530, [EMAIL PROTECTED] wrote:
>dear friends,
> i wan't to manipulate the datas in an already existing MS EXCEL
>Workbook. The code or any hints in all book does't give any idea for
>accessing the datas in an already existing EXCEL datas using OLE
Extension.
>are u clear now. please let me to know.
Hi
There is a couple of examples in the docs
(<yourPerlDir>/html/site/lib/Win32/OLE.html) and in the PerlWin32FAQ
(<yourPerlDir>/html/faq/Windows/ActivePerl-Winfaq12.html) which can be
used. This one is a slightly modified example:
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
# uses the already open Excel application or opens one
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;});
# makes Excel visible
$Excel->{Visible} = 1;
# starts a new workbook
my $Book = $Excel->Workbooks->Add;
my $Sheet = $Book->Worksheets(1);
# sets the values in the range A2:C7
my $Range = $Sheet->Range("A2:C7");
$Range->{Value} =
[['Delivered', 'En route', 'To be shipped'],
[504, 102, 86],
[670, 150, 174],
[891, 261, 201],
[1274, 471, 321],
[1563, 536, 241]];
# fetches the values in the range A8:B9
my $array = $Sheet->Range("A4:B5")->{'Value'};
print "Values in the range A4:B5 are:\n";
foreach my $ref_array (@$array) {
foreach my $scalar (@$ref_array) {
print "$scalar\t";
}
print "\n";
}
# then saves the workbook
$Book->SaveAs('test.xls');
/Henning
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users