In VB6, you could handle specific exceptions and then resume at the line of code that caused the problem to 'try again'.
In VB.net, I cannot see how this might be possible in a Try...Catch routine
If I can trap a specific exception that I know how to resolve, how can I return (resume) to the line of code that caused the problem?
For example:
Try
... other code ...
m_WordDoc = oWordApp.Documents.Open(DocPath)
... other code ...
Catch COMexc As COMException
Select Case COMexc.ErrorCode
Case -2146823114 ' doc not found
m_WordDoc = oWordApp.Documents.Add()
m_WordDoc.SaveAs(DocPath)
' happy to continue at this point
Case -2147023174 ' rpc server unavailable
owordapp = new word.application()
Resume????? Try Again?????
Case Else
MessageBox.Show(COMExc.ErrorCode)
End Select
Catch exc As Exception
MessageBox.Shgow(exc.Message)
End Try
The Error Numbered -2147023174 occurs very rarely and does not warrant checking prior to executuion each time.
Am I missing something else. How can I "Resume"...
Thanks
In VB.net, I cannot see how this might be possible in a Try...Catch routine
If I can trap a specific exception that I know how to resolve, how can I return (resume) to the line of code that caused the problem?
For example:
Try
... other code ...
m_WordDoc = oWordApp.Documents.Open(DocPath)
... other code ...
Catch COMexc As COMException
Select Case COMexc.ErrorCode
Case -2146823114 ' doc not found
m_WordDoc = oWordApp.Documents.Add()
m_WordDoc.SaveAs(DocPath)
' happy to continue at this point
Case -2147023174 ' rpc server unavailable
owordapp = new word.application()
Resume????? Try Again?????
Case Else
MessageBox.Show(COMExc.ErrorCode)
End Select
Catch exc As Exception
MessageBox.Shgow(exc.Message)
End Try
The Error Numbered -2147023174 occurs very rarely and does not warrant checking prior to executuion each time.
Am I missing something else. How can I "Resume"...
Thanks