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

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://414614]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2018-03-19 16:51 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (244 votes). Check out past polls.