I am experiencing the strangest problem. A workbook I developed a few months ago suddenly appeared to stop firing the Workbook_Open code. To test if the code was not working or the even was not being triggered, I added a msgbox at the beginning of the code. With the msgbox, the entire code triggers and executes correctly. Without the msgbox, nothing happens. I have never seen this before. I am sure events are enabled and all that jazz and I have tested the msgbox thing three times. It always works with the msgbox and doesn't work without it.
Private Sub Workbook_Open()
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
MsgBox "Workbook open code starting now. Press OK."
Application.DisplayAlerts = False
Sheets("ITEMDB").Delete
Sheets("VENDDB").Delete
'copy databases
Dim DBWB As Workbook
Set DBWB = Workbooks.Open(DBPATH)
DBWB.Sheets(Array("ITEMDB", "VENDDB")).Copy After:=ThisWorkbook.Sheets(Sheets.Count)
DBWB.Close (False)
'delete unnecessary names
For Each nname In ThisWorkbook.Names
If InStr(1, UCase(nname.RefersTo), "#REF!") > 0 Or InStr(1, UCase(nname.RefersTo), "SERVER") > 0 Then nname.Delete
Next nname
Sheets(1).Activate
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Bookmarks