Excel 2000
This example is a direct copy of how I can duplicate the problem. I can't figure out why the Change event would fire right after ThisWorkbook.Close. It causes an error when the workbook closes because the Change event has some activesheet references in it that aren't applicable if Workbook is closed and not on that sheet.
1. Open the excel workbook.
2. Some code dynamically enables the "cbMentalHealth" combobox in the "wksExhibitTemplate" worksheet, which is sort of a change, but not one that should cause this problem.
3. Close the excel workbook.
4. This auto_close event fires.
5. If I "Step Into" ThisWorkbook.Close False, the "Change" event of "cbMentalHealth" then fires in a totally different sheet "wksExhibitTemplate".
This example is a direct copy of how I can duplicate the problem. I can't figure out why the Change event would fire right after ThisWorkbook.Close. It causes an error when the workbook closes because the Change event has some activesheet references in it that aren't applicable if Workbook is closed and not on that sheet.
1. Open the excel workbook.
2. Some code dynamically enables the "cbMentalHealth" combobox in the "wksExhibitTemplate" worksheet, which is sort of a change, but not one that should cause this problem.
3. Close the excel workbook.
4. This auto_close event fires.
Code:
Sub auto_close()
ThisWorkbook.Close False
End Sub
Code:
Private Sub cbMentalHealth_Change()
...some code errors because it references active sheet inappropriately
End Sub