Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Before Save Event is not working when called from another Procedure
Hi All,
I've taken several stabs at this and am not getting anywhere. When I use the save button on the toolbar, the BeforeSave event below works as expected. However, when I envoke a save from another macro (btnSave), the event does not actually save when the filename is not the recommended name. When a macro button is pressed, this event should check if the file name matches the recommended name (ie Draft1.xls), if not (ie Draft2.xls) the user shoule be prompted with the SaveAs Dialog box. The user may or may not rename the file. When the user presses SAVE on the dialog box, the file should save ... but it does not. Any help would be appreciated. thanks, TW Baker -------------------------------------------------------- Sub btnSave() ThisWorkbook.Save End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) tmpString = "Draft1.xls" '****RECOMMENDED NAME If ThisWorkbook.Name < tmpString Then vfile = Application.GetSaveAsFilename(tmpString) If vfile < False Then Application.EnableEvents = False ThisWorkbook.SaveAs vfile '***This does not happen when save is called from another macro. Application.EnableEvents = True Cancel = True Else Cancel = True End If End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
after save event/procedure | Excel Programming | |||
Event Procedure not working | Excel Programming | |||
procedure continuously being called | Excel Programming | |||
Shared Workbook; Update-on-Save not working when called from code? | Excel Programming | |||
Save Event - Determine if called by code or user | Excel Programming |