in reply to Adding Hyperlink to a MS Word Document using Win32:OLE

Hi roshmont,

I have written a short example to get you started:
#!/usr/bin/perl use strict; use warnings; use Win32::OLE; my $word = Win32::OLE->new('Word.Application') or die $!; $word->{'Visible'} = 1; my $document = $word->Documents->Add; my $selection = $word->Selection; $selection->TypeText("Click here"); my $range = $word->ActiveDocument->Content; $document->Hyperlinks->Add({ Anchor => $range, Address => "http://www.perlmonks.org" });

Hope this helps.

Martin

Replies are listed 'Best First'.
Re^2: Adding Hyperlink to a MS Word Document using Win32:OLE
by roshmont (Initiate) on Feb 03, 2006 at 17:36 UTC
    Martin, Thanks so much. Would you know how to define the range for the Hyperlink such that I can insert the Hyperlink at the current selection position.i.e after I have finished writing some text to the document?