mfoster711
12 years agoRegular Contributor
VBScript Error Handling guidance
I am converting a script from Rational Robot to TestComplete and I am not sure of the best method for performing error handling in the following example.
I have a script that opens Excel files performs various Excel functions. I am doing this using Sys.OleObject("Excel.Application") methods and properties. In my old code I would use on "On Error Goto Label..." to perform cleanup operations if there were any Excel errors but how do I do this in vbscript? Here is what I have in my old code:
Begin Function
One Error Goto Cleanup
Code using various Excel functions....
Cleanup:
objWorkBook.Close False
Set objRange = Nothing
Set objWorkBook = Nothing
Set objWorkSheet = Nothing
objExcel.Quit
Set objExcel = Nothing
End Function
I have a script that opens Excel files performs various Excel functions. I am doing this using Sys.OleObject("Excel.Application") methods and properties. In my old code I would use on "On Error Goto Label..." to perform cleanup operations if there were any Excel errors but how do I do this in vbscript? Here is what I have in my old code:
Begin Function
One Error Goto Cleanup
Code using various Excel functions....
Cleanup:
objWorkBook.Close False
Set objRange = Nothing
Set objWorkBook = Nothing
Set objWorkSheet = Nothing
objExcel.Quit
Set objExcel = Nothing
End Function