fredmartinmaine
IS-IT--Management
I'm getting a runtime error from this code.
It deals with Excel documents that either have a worksheet named "Current" or a worksheet named "QAReviewReport".
I'm opening the Excel document 'src_file' read Only. That works.
Then , if there is a worksheet named "Current" it activates. That works ok too.
However, if there's any error opening the "Current" worksheet, for example if it doesn't exists, I want to try to open a worksheet called "QAViewReport" instead. After I added the IF statement, it started failing. Here's the partial code:
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file,,TRUE)
oBook.Worksheets("Current").Activate
If Err.Number <> 0 Then
oBook.Worksheets("QAReviewReport").Activate
End If
If neither exists I'll accept a runtime error. Again, it works fine if there is a "Current" worksheet, and if I comment out the If / End If lines.
I'm hoping this is just a syntax error. Any ideas?
It deals with Excel documents that either have a worksheet named "Current" or a worksheet named "QAReviewReport".
I'm opening the Excel document 'src_file' read Only. That works.
Then , if there is a worksheet named "Current" it activates. That works ok too.
However, if there's any error opening the "Current" worksheet, for example if it doesn't exists, I want to try to open a worksheet called "QAViewReport" instead. After I added the IF statement, it started failing. Here's the partial code:
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file,,TRUE)
oBook.Worksheets("Current").Activate
If Err.Number <> 0 Then
oBook.Worksheets("QAReviewReport").Activate
End If
If neither exists I'll accept a runtime error. Again, it works fine if there is a "Current" worksheet, and if I comment out the If / End If lines.
I'm hoping this is just a syntax error. Any ideas?