EDIT: Missed an 'n' in the subject. Should be 'then fails to run again'
I have a WB containing quite a few Subs. Workbook_Open code calls these and was working but it now fails. Trouble-shooting so far:
Copy all sheets and code to a new WB and compile code (no issues).
a) The Workbook_Open Code ran
b) Save and close the workbook, open again. Workbook_Open - failed (tested repeatedly).
c) Move all Workbook_Open Code to it's own module, rename the Sub OpenWB() Make it Public. Create new Workbook_Open() code with a single line OpenWB - failed.
d) insert Msgbox "test" as the first line - failed
e) Delete Workbook_Open Code. Create Workbook the following
Private Sub Workbook_Activate()
MsgBox "OK"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "OK"
End Sub
Both Subs functioned repeatedly
f) Recreate
Private Sub Workbook_Open()
MsgBox "OK"
End Sub
It fails to run.
g) Create a New workbook
insert the code
Private Sub Workbook_Open()
MsgBox "OK"
End Sub
Repeatedly open and close the workbook, the "OK" message appears as it should each time.
h) Restart PC test the workbook created from the original again. It still fails.
Copying sheets and code to a new workbook tested three times for identical results.
Can anyone suggest a reason Workbook_Open may be corrupted after running successfully once only in a workbook?
I have a WB containing quite a few Subs. Workbook_Open code calls these and was working but it now fails. Trouble-shooting so far:
Copy all sheets and code to a new WB and compile code (no issues).
a) The Workbook_Open Code ran
b) Save and close the workbook, open again. Workbook_Open - failed (tested repeatedly).
c) Move all Workbook_Open Code to it's own module, rename the Sub OpenWB() Make it Public. Create new Workbook_Open() code with a single line OpenWB - failed.
d) insert Msgbox "test" as the first line - failed
e) Delete Workbook_Open Code. Create Workbook the following
Private Sub Workbook_Activate()
MsgBox "OK"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "OK"
End Sub
Both Subs functioned repeatedly
f) Recreate
Private Sub Workbook_Open()
MsgBox "OK"
End Sub
It fails to run.
g) Create a New workbook
insert the code
Private Sub Workbook_Open()
MsgBox "OK"
End Sub
Repeatedly open and close the workbook, the "OK" message appears as it should each time.
h) Restart PC test the workbook created from the original again. It still fails.
Copying sheets and code to a new workbook tested three times for identical results.
Can anyone suggest a reason Workbook_Open may be corrupted after running successfully once only in a workbook?
Last edited: