Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

In Re: Hyperlinks with win32::word::writer, regarding Win32::Word::Writer, NetWallah was kind enough to to tweak a hyperlink example so that it is clickable using VB methods. Using the same script below, is there a way to show text and build hyperlinks from this text rather than the link itself, for example: <a href="http://www.perlmonks.org">PerlMonks</a> (link to www.perlmonks.org). Thank you so much for any guidance.
use strict; use Win32::Word::Writer; my $oWriter = Win32::Word::Writer->new(); $oWriter->WriteParagraph("Testing", heading => 1); $oWriter->WriteParagraph("", style => "Heading 9"); $oWriter->NewParagraph(); $oWriter->TableBegin(); $oWriter->TableRowBegin(); #$oWriter->TableColumnBegin(); $oWriter->SetBold(0); $oWriter->TableColumnBegin(); $oWriter->Write("Column 1"); # $oWriter->TableColumnBegin(); $oWriter->Write("Column 2"); $oWriter->TableColumnBegin(); $oWriter->Write("URL"); my $counter = 0; my @urls = qw (http://ww.perlmonks.org http://www.perl.com http://www. +perl.org); for my $i (@urls){ $oWriter->TableRowBegin(); for my $j (0..1){ $counter++; $oWriter->TableColumnBegin(); $oWriter->Write("$counter"); } $oWriter->TableColumnBegin(); $oWriter->Write (""); # Null write, to make a selection my $sel= $oWriter->oSelection; $sel->Hyperlinks->Add( $sel->Range, $i); } $oWriter->TableEnd(); $oWriter->SaveAs("my_file.doc");

Replies are listed 'Best First'.
Re: NetWallah Where Art Thou or $o->Hyperlinks->Add( $o->Range, $i)/
by Anonymous Monk on Jun 12, 2006 at 01:52 UTC
    I managed to solve this by playing with the Hyperlinks collection using the VB Add method. It works somewhat the same as in Win32::OLE. Now I am able to display textual data independently of the URI. I appreciate your help anyway.
    =cut Object The object in which you want to insert the hyperlink. Anchor The object the user will click to follow the hyperlink. This co +uld be a section of text, a Range object, or a graphic. Address The address of the link, which can be a file path, a UNC path, + or a URL. SubAddress (optional) A named location within the linked file ScreenTip (optional) A string that specifies the banner text that appe +ars when the user hovers the mouse pointer over the link. If you omit this argument, the Addres +s is displayed. TextToDisplay (optional) A string that specifies the hyperlink text th +at appears in the document. =cut my $object = $sel->Range; my $address ="$i"; my $subaddress ="subaddress"; my $screentip ="screentip"; my $texttodisplay ="texttodisplay"; ##Hyperlinks collection Add method to insert Hyperlinks into Word $sel->Hyperlinks->Add( $object,$address,$subaddress,$screentip,$textto +display);