package readWord; use strict; use Win32::OLE qw(in with); require Exporter; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(readActiveDoc); sub readActiveDoc # this method returns the name of the active document and 2 hashes con +taining every single # word found in the document and all the document's properties. Hence +it is ready for use { if ( my $word = Win32::OLE->GetActiveObject('Word.Application'))# c +onnect to word document { if ($word->Documents->Count()) # makes sure at least one documen +t is open { # next line for debug only # print "\nSuccessfully connected to existing word"; my $docName = $word->ActiveDocument->Name; # retrieve name my $docProperties = $word->ActiveDocument->{BuiltInDocumentPr +operties}; my $wordRange = $word->ActiveDocument->Content; return ($docName,$docProperties,$wordRange); } } return (undef,undef,undef); # if code reaches this line then it has +n't reached the other return } # implying either the program's not open or there' +s no document.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
How to include the snippet elsewhere
by Foggy Bottoms (Monk) on Jun 20, 2003 at 14:24 UTC | |
|
Re: Reading data from an open Word Document
by Anonymous Monk on Dec 09, 2003 at 09:37 UTC |