Win32::OLE, Microsoft Word

B

benhollister

Hey all,
I've got a fairly large Word document with a whole bunch of anchors in
it. I'm trying to write a PERL script that will utilize the MSWord
Selection->Find command with regex enabled to find all of these
anchors, and dump them to a text file. I've got everything up and
running, and it's iterating through the entire document and catching
everyone (I know this because I did a find and replace as a test), but
I can't seem to dump whatever I select (highlight) to a var or list.
Do any of you know the method that will return what I have
highlighted? Ideally it would be like:
my $anchor = $word->someHiddenMethod->text()
or something like that.

Thanks,
- Ben Kershner
 
B

benhollister

Hey all,
I've got a fairly large Word document with a whole bunch of anchors in
it. I'm trying to write a PERL script that will utilize the MSWord
Selection->Find command with regex enabled to find all of these
anchors, and dump them to a text file. I've got everything up and
running, and it's iterating through the entire document and catching
everyone (I know this because I did a find and replace as a test), but
I can't seem to dump whatever I select (highlight) to a var or list.
Do any of you know the method that will return what I have
highlighted? Ideally it would be like:
my $anchor = $word->someHiddenMethod->text()
or something like that.

Thanks,
- Ben Kershner

I finally figured it out. The key was the use of the valof command in
the Win32::OLE module. When I searched using:
my $search = $word->Selection->Find;
$search->Execute();

I could grab the contents with:
print Win32::OLE::valof($word->Selection->Range->Text),"\n";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,592
Members
45,103
Latest member
VinaykumarnNevatia
Top