Public MacroRunFlag As Boolean
Sub test()
MsgBox "Hello"
MacroRunFlag = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = MacroRunFlag
End Sub
Private Sub Workbook_Open()
Cancel = MacroRunFlag
Saved = True
End Sub
Change the Workbook BeforeSave event code to:
Code:Private Sub Workbook_Open() Cancel = MacroRunFlag Saved = True End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = MacroRunFlag
Saved = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If MacroRunFlag = True Then
MsgBox "File will not save after running the Macro."
Cancel = MacroRunFlag
Saved = True
End If
End Sub
Do you still have the MacroRunFlag as a public variable in your module.
Have you set this to TRUE at the end of your macro?