Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Avoiding Win32::OLE errors

by esr (Scribe)
on Dec 14, 2004 at 06:42 UTC ( #414614=note: print w/ replies, xml ) Need Help??


in reply to Avoiding Win32::OLE errors

I'm relatively new to PerlMonks so I wasn't sure whether I should respond to the others' comments on this subject or not. The suggestions offered here were interesting and led to some useful information but did not solve the problem. However I did find a hokey way around this specific case. In this situation it appears that closing Word causes the $word object to point to invalid stuff and that is what seems to be causing the error messages. I experimented with various combinations and found that the following code bypasses the problem of the Perl script being terminated although there is still a warning message issued. The code that seems to work for this case is:

$icount = $word->Documents->Count(); $done = 0; while ($done == 0) { if ($word->Documents) { if (($mycnt = $word->Documents->Count()) != $icount) { $done = 1; } } else { undef $word; $word = Win32::OLE->GetActiveObjectord.Application') || Win32::OLE->new('Word.Application'); $done = 1; } sleep 5; }
As I say, it's hokey but it seems to work for this specific case.


Comment on Re: Avoiding Win32::OLE errors
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://414614]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-09-03 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (34 votes), past polls