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: 1
Default Save Fail on Excel Close

I have a workbook that requires macros enabled to use properly.

I have created a worksheet with a warning message that will only be hidden by
a startup macro and to ensure this displays, I have the following code for
the BeforeSave event that shows the sheet, hides all others and then reverses
this after the save.

This works great when the user chooses Save or SaveAs, however when the user
closes the workbook and chooses to save, the save does not happen. The save
name for a new workbook does not get passed and SaveUI has a value of False.

Does anyone have any ideas why this should happen and what I can do to solve
this issue?



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

Application.EnableEvents = False

'<Optional - this would be before save code
If SaveAsUI Then
sFile = Application.GetSaveAsFilename(, "Excel Files (*.xls), *.xls")
End If

SetMacroWarn

If SaveAsUI Then
If sFile < False Then
ThisWorkbook.SaveAs sFile
ThisWorkbook.Saved = True
'<Optional - this would be after save code
RemoveMacroWarn

End If
Else
ThisWorkbook.Save
ThisWorkbook.Saved = True
'<Optional - this would be after save code
RemoveMacroWarn
End If
Application.EnableEvents = True

Cancel = True

End Sub

 
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
Open and Save fail after SP1 Meltivore Setting up and Configuration of Excel 0 December 18th 07 11:43 PM
Macros Referenced in Custom Menu Fail after Save Kevin M[_2_] Excel Programming 6 April 20th 07 09:06 PM
How do you force excel to save on close Tom Hewitt Excel Discussion (Misc queries) 3 September 21st 06 10:55 AM
Close excel do not save Steved Excel Worksheet Functions 2 September 9th 05 02:54 AM
Save and Close Excel using OnTime shockley Excel Programming 1 July 20th 04 06:48 AM


All times are GMT +1. The time now is 04:46 AM.

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"