Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Win32::OLE and Excel

by vladdrak (Monk)
on Sep 19, 2000 at 03:20 UTC ( #33039=note: print w/replies, xml ) Need Help??

in reply to Win32::OLE and Excel

I do a fair amount of work with Win32::OLE and it's always a good idea to check errors after certain operations. Otherwise, debugging can be quite painful down the road, or if one OLE call dies and snowballs. I use an OLE error checking sub like so:
$obj=Win32::OLE->GetObject("IIS://localhost/W3SVC/1"); &OLEErrChk("Binding to W3SVC1",1)
That way you can also trap common errors and act on them, also.
sub OLEErrChk { my $operation=shift; my $critical=shift; my $errnum=Win32::OLE->LastError; if(!$errnum) { if ($errnum=~/0x80070094/) { print "$operation Failed (in use) trying something..\n"; &Something; } else { print "$operation Failed: $errnum\n"; die if ($critical); } } else {print "$operation was Successful.\n"} }
Hope that helps, Vlad

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2023-01-31 11:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found