K
kleefaj
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.
By the way, when I assign the return value of the
GetCrossReferenceItems to a scalar (instead of an array) I get the
following output:
ARRAY(0x1bfc7a8)Done!
Any thoughts?
-Jeff
==============================
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.
By the way, when I assign the return value of the
GetCrossReferenceItems to a scalar (instead of an array) I get the
following output:
ARRAY(0x1bfc7a8)Done!
Any thoughts?
-Jeff