Trapping error returned from COM object

Hi All

Can anyone tell me how to trap an error returned from a COM object.

For example:

If "Sheet1" doesn't exist in
chSheet = chBook:Sheets:Item("Sheet1")
then we get an error dialog

If "Sheet1" doesn't exist in
chSheet = chBook:Sheets:Item("Sheet1") NO-ERROR
then we don't get the error dialog but how can we trap it?

Cheers
 

dayv2005

Member
Hi All

Can anyone tell me how to trap an error returned from a COM object.

For example:

If "Sheet1" doesn't exist in
chSheet = chBook:Sheets:Item("Sheet1")
then we get an error dialog

If "Sheet1" doesn't exist in
chSheet = chBook:Sheets:Item("Sheet1") NO-ERROR
then we don't get the error dialog but how can we trap it?

Cheers

adding the no error on the second one dosen't really fix it. You actually are still getting the same error but you use no-error when you want to overide progress's default error handling.

So to test and see if you are still getting an error with teh no error do this:

chSheet = chBook:Sheets:Item("Sheet1") NO-ERROR
if error-status:num-messages <> 0 then
message "There is an error".


What is it that you are tring to do that gives you your error. I don't mess with excel much if that is what it is. But i did a lot with office.
 
adding the no error on the second one dosen't really fix it. You actually are still getting the same error but you use no-error when you want to overide progress's default error handling.

So to test and see if you are still getting an error with teh no error do this:

chSheet = chBook:Sheets:Item("Sheet1") NO-ERROR
if error-status:num-messages <> 0 then
message "There is an error".


What is it that you are tring to do that gives you your error. I don't mess with excel much if that is what it is. But i did a lot with office.

Cheers for that. I didn't realise you could trap the COM error using the ERROR-STATUS handle. Should have checked before asking the question!

I'm not getting an specific error messages via Excel, I am just tightening the code up with some decent error handling.

We have been using DDE to Excel for years and years but are migrating to COM as there are various Macro 4.0 functions not supported in Excel 2007.

One of my next projects is an Progress-to-Outlook interface so if you had a procedure library already I would be very keen to take a look...
 

dayv2005

Member
Cheers for that. I didn't realise you could trap the COM error using the ERROR-STATUS handle. Should have checked before asking the question!

I'm not getting an specific error messages via Excel, I am just tightening the code up with some decent error handling.

We have been using DDE to Excel for years and years but are migrating to COM as there are various Macro 4.0 functions not supported in Excel 2007.

One of my next projects is an Progress-to-Outlook interface so if you had a procedure library already I would be very keen to take a look...

Sweet man, good job. As for the outlook one Like i said if you need any help on that you can pm me. I got one working with a few bugs in it that i have to work out by the 10th for our salesmen meeting haha nothing is worst than something not working when everone nation wide is together haha.

But heads up that outlook interface. if your using OE10+ take advantage of the Date-Time Datatype. If anything lower you have to do it the hard way for appointments. You have to import the appointment to a txt file and substring out the data. bc there's no date-time datatype in the older versions :(.

Plus there were many kind souls who helped me from here and peg and Mapi forums :)
 
Sweet man, good job. As for the outlook one Like i said if you need any help on that you can pm me. I got one working with a few bugs in it that i have to work out by the 10th for our salesmen meeting haha nothing is worst than something not working when everone nation wide is together haha.

But heads up that outlook interface. if your using OE10+ take advantage of the Date-Time Datatype. If anything lower you have to do it the hard way for appointments. You have to import the appointment to a txt file and substring out the data. bc there's no date-time datatype in the older versions :(.

Plus there were many kind souls who helped me from here and peg and Mapi forums :)

Cheers for that. I may indeed pm you in the future for some Outlook expertise.
 
Top