LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Save not triggering Before_Save event

I have a before_save event that runs when I click the save icon on the tool
bar or through the menu. But if I have a command button with this code:

Private Sub Save_Click()

ThisWorkbook.Save

End Sub

the Before_save event is called but the files does not save.

This is the code for the before_save event:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim Fname As String

If IsEmpty(Sheet1.Range("F3")) Then _
If IsEmpty(Sheet1.Range("F4")) Then Exit Sub

If Not IsEmpty(Sheet1.Range("F3")) Then _
If IsEmpty(Sheet1.Range("F4")) Then _
Fname = Sheet1.Range("F3").Value

If Not IsEmpty(Sheet1.Range("F4")) Then _
If IsEmpty(Sheet1.Range("F3")) Then _
Fname = Sheet1.Range("F4").Value

If Not IsEmpty(Sheet1.Range("F3")) Then _
If Not IsEmpty(Sheet1.Range("F4")) Then _
Fname = Sheet1.Range("F3").Value & "-" & Sheet1.Range("F4").Value

On Error GoTo DumpSub

Application.EnableEvents = False
Cancel = True
Application.Dialogs(xlDialogSaveAs).Show Fname

DumpSub:
Application.EnableEvents = True

End Sub

Why would the before_save event work with menu and toolbar commands but not
with a save event triggered through code?

Thanks,

Scott
 
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
Combo Box Event code self triggering?? Sam Excel Programming 0 August 13th 08 05:10 PM
RTD value changes not triggering worksheet change event DTM[_4_] Excel Programming 2 June 7th 06 05:01 PM
Canceling Workbook Before_Save event [email protected] Excel Programming 2 May 23rd 06 02:54 PM
Before_Save event quartz[_2_] Excel Programming 3 September 20th 05 12:36 AM
Triggering an event based on reference Supriya Excel Programming 0 January 29th 04 11:50 AM


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

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

About Us

"It's about Microsoft Excel"