How do I disable the save icon in a workbook? I've tried this:
and assigned it to a button but to no avail. Any suggestions?![]()
Sub DisableSaveButton Application.CommandBars("Standard").FindControl(ID:=3).Enabled = False End Sub
How do I disable the save icon in a workbook? I've tried this:
and assigned it to a button but to no avail. Any suggestions?![]()
Sub DisableSaveButton Application.CommandBars("Standard").FindControl(ID:=3).Enabled = False End Sub
BETTER SOLUTION:
define a boolean variable, set to false on workbook open
on BeforeSave event, check if boolean is false, if so cancel save, exit procedure and tell user they must use a custom button to save the file
![]()
SaveFormButtonClicked as Boolean
![]()
Private Sub Workbook_Open() SaveFormButtonClicked = False End Sub
![]()
Sub SaveFormAsXLSX ThisWorkbook.SaveFormButtonClicked = True 'save commands ThisWorkbook.SaveFormButtonClicked = False End Sub
From my testing so far, going this route will disable the Save icon on ribbon, the Save menu item, the Save As menu item, and the Save keyboard shortcut.![]()
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If SaveFormButtonClicked = False Then MsgBox "The save button you just clicked is disabled. Please use the 'Save Form' button on the right of the spreadsheet.", vbInformation, "Standard Saving Is Disabled" Cancel = True Exit Sub End If
...ok, so it doesn't actually disable these items, it prevents the user from being able to use them to save the file...basically forces them to use a control button you've placed on the sheet.
Still curious as to why the code in my OP doesn't work though
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks