--------8<------
It works well but I'm searching something particular. I need to write a
hyperlink inside a cell and displaying something else as the text.
--------8<------
You should record a macro and convert the generated VBA to Perl to see
where youre going.
The trick with this is to treat the Hyperlinks Add call as a hash.
However if all you want to do is add hyperlinks it's a lot easier to use
Spreadsheet::WriteExcel. But then again Win32::OLE allows you a lot more
functionality, and as your code and requirements grow you'll probably
want to stick with Win32::OLE.
Suggest you read up on perlmonks as they have some very good examples.
Here's some working code:-
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
my $File = 'C:\\Temp\\OLE.xls';
unless(-e $File)
{
open(XLS, ">$File") or die "Cant write to $File:- $!";
close XLS;
}
my $Excel = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application', 'Quit');
$Excel->{Visible} = 1;
my $Book = $Excel->Workbooks->Open($File);
my $Sheet = $Book->Worksheets(1);
my $Selection = $Sheet->Range("A1");
$Sheet->Hyperlinks->Add({Anchor => $Selection,
Address => "http://activestate.com",
TextToDisplay => "AS",
ScreenTip => 'is da bomb'});
Cheers,
Just in
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs