View Single Post
  #1   Report Post  
Posted to comp.lang.perl.modules,comp.lang.perl.misc,microsoft.public.excel.misc,microsoft.public.excel.links,microsoft.public.excel.programming
-b -b is offline
external usenet poster
 
Posts: 1
Default Win32::OLE.pm and Hyperlinks

Paul Lalli wrote in message ...
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/en...hyperlinks.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