I'm glad poj's other solution is working for you.
Since you continued the discussion in this sub-thread after declaring the other solution as working, I assumed you still wanted to investigate my alternative. My further post was to provide a framework to further debug the issue, since my code worked exactly as I expected for me, but apparently didn't for you. If you're still interested, feel free to run the code and, if the results don't match mine, post your results.
Whether or not you continue down my bunny trail, I suggest changing
my $MSWord = Win32::OLE->new('Word.Application') or die $!;
$MSWord->{'Visible'} = 1;
my $doc = $MSWord->Documents->Open("c:/temp/Word.doc");
... to ...
my $MSWord = Win32::OLE->new('Word.Application') or die Win32::OLE->La
+stError();
$MSWord->{'Visible'} = 1;
my $doc = $MSWord->Documents->Open("c:/temp/Word.doc") or die Win32::O
+LE->LastError();
... because Win32::OLE routines do not set $!, so error messages are not seen using the original die $! call. |