Workbook_BeforeSave Does Not Trigger

G

Guest

I have a regular module with a sub that contains code, at the end of which
the user is prompted to save the file (or not); the code is below. If the
user elects to save, then code that resides in ThisWorkbook under a
Workbook_BeforeSave module does not fire. Enable events is on. Can someone
advise what I'm doing wrong here?

MsgBox ("Processing has completed; save the file now, under a different" & _
"file name. If you don't want to save it, select 'Cancel' on the next
menu.")
FName = Application.GetSaveAsFilename(InitialFileName:="",
FileFilter:="Microsoft Excel Workbook (*.xls), *.xls")
If FName <> False Then
ActiveWorkbook.SaveAs Filename:=FName, FileFormat:=xlWorkbookNormal
End If
 
G

Guest

That works on my machine... The Before Save event is triggered. Try adding a
line to enable events right before the save as to ensure your events are
firing. Events can be the darnedest things... other than that place a massage
box or a break point in the before save event code to ensure that it truely
is not being called...

MsgBox ("Processing has completed; save the file now, under a different" & _
"file name. If you don't want to save it, select 'Cancel' on the next
menu.")
FName = Application.GetSaveAsFilename(InitialFileName:="", _
FileFilter:="Microsoft Excel Workbook (*.xls), *.xls")
If FName <> False Then
Application.EnableEvents = True '***
ActiveWorkbook.SaveAs Filename:=FName, FileFormat:=xlWorkbookNormal
End If
 
G

Guest

Thanks, Jim. Will give this a try.

Jim Thomlinson said:
That works on my machine... The Before Save event is triggered. Try adding a
line to enable events right before the save as to ensure your events are
firing. Events can be the darnedest things... other than that place a massage
box or a break point in the before save event code to ensure that it truely
is not being called...

MsgBox ("Processing has completed; save the file now, under a different" & _
"file name. If you don't want to save it, select 'Cancel' on the next
menu.")
FName = Application.GetSaveAsFilename(InitialFileName:="", _
FileFilter:="Microsoft Excel Workbook (*.xls), *.xls")
If FName <> False Then
Application.EnableEvents = True '***
ActiveWorkbook.SaveAs Filename:=FName, FileFormat:=xlWorkbookNormal
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top