Home > Archive > PERL Miscellaneous > July 2004 > Win32::OLE.pm and Hyperlinks
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Win32::OLE.pm and Hyperlinks
|
|
|
| I am using Perl and OLE.pm to read and modify an Excel spreadsheet.
I can read the hyperlinked value of a cell using the following code:
my $cellObject = $worksheet->Range("A2");
my $hyperlink = $cellObject->Hyperlinks(1)->Address;
Can anyone explain how to modify the value of an Excel cell's
hyperlink, or to add one to a cell if it has no hyperlink?
-docuSwear
| |
| Paul Lalli 2004-07-22, 3:57 pm |
| On Thu, 22 Jul 2004, -b wrote:
> I am using Perl and OLE.pm to read and modify an Excel spreadsheet.
>
>
> I can read the hyperlinked value of a cell using the following code:
>
> my $cellObject = $worksheet->Range("A2");
> my $hyperlink = $cellObject->Hyperlinks(1)->Address;
>
>
>
> Can anyone explain how to modify the value of an Excel cell's
> hyperlink, or to add one to a cell if it has no hyperlink?
Disclaimer - I've never used this, nor tried to.
Based on MS's reference at:
http://msdn.microsoft.com/library/e...jhyperlinks.asp
I would try:
$cellObject->Hyperlinks->Add(Range('A2'), 'http://www.msdn.com');
Paul Lalli
| |
|
| Paul Lalli <mritty@gmail.com> wrote in message news:<20040722151505.M2467@barbara.cs.rpi.edu>...
> On Thu, 22 Jul 2004, -b wrote:
>
>
> Disclaimer - I've never used this, nor tried to.
>
> Based on MS's reference at:
> http://msdn.microsoft.com/library/e...jhyperlinks.asp
>
> I would try:
>
> $cellObject->Hyperlinks->Add(Range('A2'), 'http://www.msdn.com');
>
> Paul Lalli
Thanks for the effort Paul, but that did not work. It threw an error:
"Undefined subroutine &main::Range called at line 58."
I changed the syntax around, but to no avail.
$cellObject->Hyperlinks->Add({Anchor=>('D39'),Address=>'http://www.msdn.com'});
$cellObject->Hyperlinks->Add({Range=>('D39'),Address=>'http://www.msdn.com'});
$cellObject->Hyperlinks->Add(Range=>('D39'),Address=>'http://www.msdn.com');
Nothing seems to work.
I also tried the following structure, but that did not work either.
$worksheet->Range("D39")->Select();
$worksheet->Hyperlinks()->Add({ Address => "C:\\temp",
Anchor => Selected,
TextToDisplay => "Automated Link",
});
I also tried substituting 'Range("D39")' for the "Selected" value,
which did not work.
I've tried every variation I can think of, but have not been
successful yet.
-docuSwear
| |
|
| PerlMonks.org posted the correct solution to my stated problem.
my $range1 = $worksheet->Range("D39");
my $adr = "http://www.StructureHomesAZ.com";
my $txt = "D39 TEXT";
my $tip1 = "D39 TIP";
$worksheet->Hyperlinks->Add({
Anchor => $range1,
Address => $adr,
TextToDisplay => $txt,
ScreenTip => $tip1,
});
Regards,
-docuSwear
|
|
|
|
|