Click here to get back home

Win32::OLE.pm and Hyperlinks

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Win32::OLE.pm and Hyperlinks -b 07-22-2004
Posted by -b on July 22, 2004, 1:09 pm
Please log in for more thread options
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


Posted by Paul Lalli on July 22, 2004, 4:18 pm
Please log in for more thread options
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-us/off2000/html/xlobjhyperlinks.asp

I would try:

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

Paul Lalli


Posted by -b on July 23, 2004, 9:42 am
Please log in for more thread options
> 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-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();
$cellObject->Hyperlinks->Add();
$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


Posted by -b on July 23, 2004, 2:09 pm
Please log in for more thread options
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


Similar ThreadsPosted
Pod syntax and hyperlinks to =item entries December 8, 2005, 8:37 pm
Dave Roth's site (Win32::AdminMisc, Win32::ODBC, etc.) not available. December 22, 2005, 8:46 am
Problems installing Win32-Setupsup, Win32-CtrlGUI October 10, 2004, 12:31 am
Win32-PerfMon on Win32 October 26, 2004, 1:12 pm
Win32::API, please help August 10, 2004, 10:02 am
Win32::API September 22, 2005, 2:00 pm
WIN32::API on .net April 4, 2005, 5:44 am
WIN32::API on .net April 4, 2005, 7:06 am
win32 April 26, 2006, 9:12 am
Help on Win32 API June 20, 2007, 9:53 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap