Disable save button

  • Thread starter Thread starter xargon
  • Start date Start date
Try this

Don't forget the shortcut Ctrl-S (application.onkey)


Sub menuItem_Enabledfalse()
Dim a As Integer
On Error Resume Next
For a = 1 To Application.CommandBars.Count
For Each ctl In CommandBars(a).Controls
Application.CommandBars(a).FindControl(Id:=3, Recursive:=True).Enabled = False
Next ctl
Next a
End Sub

Sub menuItem_Enabledtrue()
Dim a As Integer
On Error Resume Next
For a = 1 To Application.CommandBars.Count
For Each ctl In CommandBars(a).Controls
Application.CommandBars(a).FindControl(Id:=3, Recursive:=True).Enabled = True
Next ctl
Next a
End Sub
 
Another way might be to just stop the save.

This goes behind the ThisWorkbook module in the VBE:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "No saving"
Cancel = True
End Sub

But if the user disables macros or just disables event handling, then they could
save.

You could have the same trouble with any kind of save prohibition, though.

(It won't stop the determined!)
 
This might not do what you want, but you could use a
password for editing on the file. If someone doesn't have
the password, they can't save the file with the same
name. They can save it under another name, tho.
 
Back
Top