Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's a simple implementation of the BeforeSave that takes into account
whether the user wants to Save As (SaveAsUI = True) or just Save (SaveAsUI = False): Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Cancel = True If SaveAsUI Then ' user wants to Save As Application.EnableEvents = False Application.Dialogs(xlDialogSaveAs).Show Application.EnableEvents = True Else ' user wants to Save Application.EnableEvents = False ThisWorkbook.Save Application.EnableEvents = True End If End Sub - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions http://PeltierTech.com _______ "Elkar" wrote in message ... I have a workbook that I am requiring Macros to be activated in order to use. I've managed to do this by using the following code in the BeforeSave event: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Cancel = True Application.EnableEvents = False Application.ScreenUpdating = False ActiveWorkbook.Unprotect ("password") Worksheets("Warning").Visible = True Worksheets("Time Sheet").Visible = False Worksheets("Data Sheet").Visible = False ActiveWorkbook.Protect ("password") ActiveWorkbook.Save Application.EnableEvents = True ActiveWorkbook.Unprotect ("password") Worksheets("Time Sheet").Visible = True Worksheets("Data Sheet").Visible = True Worksheets("Warning").Visible = False ActiveWorkbook.Protect ("password") Application.ScreenUpdating = True ThisWorkbook.Saved = True End Sub This works great, except that the user can't use "Save As..." to change the filename. Even if I use the line Activeworkbook.SaveAs, it still only saves over the original filename. How can I modify this so that Save As will work? Any help is much appreciated. Thanks in advance! Elkar |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 | Excel Discussion (Misc queries) | |||
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION | Excel Discussion (Misc queries) | |||
"Save" and "Save As" options greyed out - "Save as Webpage" option | Excel Discussion (Misc queries) | |||
"Subscript out of range" error for: Workbooks("Test1.xls").Save | Excel Programming | |||
save and restore "Workbook Menu Bar" & "Cell" menus | Excel Programming |