Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Win32::OLE and Excel

by vladdrak (Monk)
on Sep 19, 2000 at 03:20 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (8)
As of 2024-04-24 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found