Reputation: 11
When running automatically via Workbook_Open, it throws a 91 error. However, running the same code manually does not. It's machine specific. No problems on a different PC. Also, error 91 does not get caught in the error trap. I've checked all my Trust Center setting between the two PCs. Identical. What could this be?
Private Sub Workbook_Open()
On Err GoTo ErrHandler
Application.DisplayAlerts = False
Debug.Print "point 1. Err# = " & Err.Number
Workbooks.Open "any file and path here"
Debug.Print "Point 2. Err# = " & Err.Number
Application.DisplayAlerts = True
Debug.Print "point 3. Err# = " & Err.Number
ErrHandler:
Debug.Print "point 4. Err# = " & Err.Number
End Sub
Output when run automatically upon Workbook_Open:
point 1. Err# = 0
point 2. Err# = 91
point 3. Err# = 91
point 4. Err# = 91
Notice that at point 3 the code avoids the error trap even though there is a 91 error.
Output when the code is triggered manually:
point 1. Err# = 0
point 2. Err# = 0
point 3. Err# = 0
point 4. Err# = 0
Upvotes: 0
Views: 104
Reputation: 11
The machine it was failing on had an Excel Add-Ins "Euro Currency Tools". Add-In selected. Turn this off and errors go away. I was able to do the same on the 'good' machine as well.
Upvotes: 1