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

Update...sometimes you just need to write it down to figure it out!! I just replaced $bookmark->{Name} with Testbookmark and it worked so now I can carry on, thanks anyway Monks!

I'm very new to perl however have already used it to do some very cool text manipulation and finding it very powerful so far, keen to learn more.

I've been struggling for a long while trying to figure this out and I can't find any exact examples.

I've got about 50 word documents to update with the same fields over and over so I want to automate the process.

I have a standard output file which I'm going to read data from then paste into a Word document at the appropriate places.

I've set up a Word doc as a template with Bookmarks in it in the areas I need to update.

I have a script that can open the word document, the part I am struggling with is how to move the cursor to a specific bookmark location in the word doc. I have called the bookmark Testbookmark.

I think I'm going to need to do something like

$document->ActiveWindow->Selection -> GoTo(wdGoToBookmark, 0, 0, $bookmark->{Name}); But I'm not sure how to specify the $bookmark->{Name} section.

Would really appreciate some help. :)

So far I have:

use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $ObjectClass = "Word.Application"; my $File2 = "c:\\_test\\templateOUT.docx"; my $Word = Win32::OLE->GetActiveObject($ObjectClass) || Win32::OLE->new($ObjectClass, 'Quit'); $Word->{'Visible'} = 1; $Word->Documents->Open("C:\\_test\\template.docx") || die("Unable to o +pen template document ", Win32::OLE->LastError()); my $document = $Word->ActiveDocument; # selection is the insertion point. my $selection = $Word->Selection; my $mytxt = "Comment Text"; $Word->Selection->TypeText ({Text => $mytxt}); $Word->ActiveDocument->SaveAs({FileName => $File2}); $Word->Quit();