K
kleefaj
Greetings.
I'm trying to extract the Headings from a Word 2003 document using
Perl. The VBA version of this script works.
Here's the script:
==============================
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Word';
my $Word = Win32::OLE->new('Word.Application', 'Quit');
$Word->Documents->Open("C:\\mydoc.doc") || die("Unable to open document
", Win32::OLE->LastError());
my @i =
$Word->ActiveDocument->GetCrossReferenceItems(wdRefTypeHeading);
foreach (@i) {
# print "$_\n";
print "got one!\n";
}
$Word->Quit;
print "Done!\n";
==============================
This line
$Word->ActiveDocument->GetCrossReferenceItems(wdRefTypeHeading)
should return an array of strings. It works in VBA. I commented out
print "$_\n";
so I could see if the loop runs at all. My output is
got one!
Done!
but I'm expecting to see "got one!" about twenty times. I figure it has
something to do with the way I'm loading the array.
Any thoughts?
-Jeff
I'm trying to extract the Headings from a Word 2003 document using
Perl. The VBA version of this script works.
Here's the script:
==============================
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Word';
my $Word = Win32::OLE->new('Word.Application', 'Quit');
$Word->Documents->Open("C:\\mydoc.doc") || die("Unable to open document
", Win32::OLE->LastError());
my @i =
$Word->ActiveDocument->GetCrossReferenceItems(wdRefTypeHeading);
foreach (@i) {
# print "$_\n";
print "got one!\n";
}
$Word->Quit;
print "Done!\n";
==============================
This line
$Word->ActiveDocument->GetCrossReferenceItems(wdRefTypeHeading)
should return an array of strings. It works in VBA. I commented out
print "$_\n";
so I could see if the loop runs at all. My output is
got one!
Done!
but I'm expecting to see "got one!" about twenty times. I figure it has
something to do with the way I'm loading the array.
Any thoughts?
-Jeff