Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Save Event Handler
I am trying to "force" my user to use the "save" subroutine i have written
which utilizes the GetSaveAsFilename method with a customized dialog and a default filename. is there a way to bypass excel asking the user if they want to save if they either try to close the workbook or click the save button. i attempted this already using the workbook_beforeclose event handler and in that subroutine, put my getsaveasfilename method and it prompeted the user to save again and when it went to close the workbook finally, ran through the beforeclose event handler again. any help is appreciated, TIA |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Save Event Handler
Try code like the following in the ThisWorkbook module:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim FName As Variant On Error GoTo ExitSub If SaveAsUI = True Then Cancel = True FName = Application.GetSaveAsFilename(FileFilter:="Excel Files (*.xls),*.xls") If FName = False Then ' user cancelled Else Application.DisplayAlerts = False Application.EnableEvents = False ThisWorkbook.SaveAs Filename:=FName End If End If ExitSub: Application.EnableEvents = True Application.DisplayAlerts = True End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Spencer" wrote in message ... I am trying to "force" my user to use the "save" subroutine i have written which utilizes the GetSaveAsFilename method with a customized dialog and a default filename. is there a way to bypass excel asking the user if they want to save if they either try to close the workbook or click the save button. i attempted this already using the workbook_beforeclose event handler and in that subroutine, put my getsaveasfilename method and it prompeted the user to save again and when it went to close the workbook finally, ran through the beforeclose event handler again. any help is appreciated, TIA |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
event handler list | Excel Programming | |||
Event handler | Excel Programming | |||
Autoshape event handler? | Excel Programming | |||
Event handler is invalid | Excel Programming | |||
where is the workbook_open event handler??? | Excel Programming |