Win32::OLE.pm and Hyperlinks

B

-b

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
 
P

Paul Lalli

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/en-us/off2000/html/xlobjhyperlinks.asp

I would try:

$cellObject->Hyperlinks->Add(Range('A2'), 'http://www.msdn.com');

Paul Lalli
 
B

-b

Paul Lalli said:
Disclaimer - I've never used this, nor tried to.

Based on MS's reference at:
http://msdn.microsoft.com/library/en-us/off2000/html/xlobjhyperlinks.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
 
B

-b

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top