Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Workbook_BeforeSave Does Not Trigger

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Workbook_BeforeSave Does Not Trigger

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

--
HTH...

Jim Thomlinson


"Paige" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Workbook_BeforeSave Does Not Trigger

Thanks, Jim. Will give this a try.

"Jim Thomlinson" wrote:

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

--
HTH...

Jim Thomlinson


"Paige" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP!!!! Calling a sub from Workbook_BeforeSave RocketMan[_2_] Excel Discussion (Misc queries) 4 May 31st 07 11:47 PM
Workbook_BeforeSave question Barb Reinhardt Excel Programming 9 August 11th 06 04:17 PM
Workbook_BeforeSave() bmm Excel Programming 3 August 16th 04 03:37 PM
Workbook_BeforeSave Bill Oertell Excel Programming 5 December 21st 03 07:33 PM
Workbook_BeforeSave() in xla Bent Kjeldsen Excel Programming 6 September 24th 03 01:49 PM


All times are GMT +1. The time now is 10:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"