Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Disable save from Ctrl S

  Asked By: Gerritt    Date: Sep 15    Category: MS Office    Views: 1200
  

I am using the following code to disable the "Save" in File\Save. It
disables the Save but Ctrl S is working.


Private Sub Workbook_Activate()
Dim oCtrl As Office.CommandBarControl
For Each oCtrl In Application.CommandBars.FindControls(ID:=3)
oCtrl.Enabled = False
Next oCtrl
End Sub
I am enabling the same on Workbook Deactivate event. In the similar
manner Save as is also disabled.

How can I also disable saving a workbook from Ctrl S?

Share: 

 

7 Answers Found

 
Answer #1    Answered By: Daya Sharma     Answered On: Sep 15

Cross-posted on VBAExpress...............

 
Answer #2    Answered By: Viren Rajput     Answered On: Sep 15

I've used a Before_Save workbook  event, and
used "cancel=true" to disable  the save.

I capture the userid and check it against my own
so that *I* am allowed to save  changes, so that I can do development work.

One warning though... if a user knows how to create a macro with
Application.EnableEvents = False,
then this Before_Save event  will not function.

 
Answer #3    Answered By: Cheryl Murphy     Answered On: Sep 15

Thanks it is working  but I am able to save  the code  also.

 
Answer #4    Answered By: Adalricus Fischer     Answered On: Sep 15

I'm sorry, I'm not sure I understand.
You said "Thanks it is working"... ok, so far, so good.
But then you said "but I am able to save  the code  also".

I'm not sure what you mean. Is this a question?
A problem? Are you having some kind of undesireable result?

Is it working  and you're good to go, or is there yet more to do?

 
Answer #5    Answered By: Ada Bailey     Answered On: Sep 15

Sorry actually it is I am not able to save  the code  also.

 
Answer #6    Answered By: Martha Gonzalez     Answered On: Sep 15

OK... is that what you were WANTING?
As I mentioned in my response, in the Before_Save event,
I checked the current userid to see if it was MINE.
If it was, I allowed a save.
If not, then I used cancel = true.

Another option would be to create a couple of subs:

Sub Event_Disable()
Application.EnableEvents = False
End Sub
'---------------------------------------
Sub Event_Enable()
Application.EnableEvents = True
End Sub

Use the Event_Disable to "turn off" event  handling.
Then you can save  the workbook.
(use Event_Enable to turn it back on for testing)

 
Answer #7    Answered By: Poppy Brown     Answered On: Sep 15

I could not understand the User name option. Now I am also
using the user name and able to save.
The final code  is (for other users)

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
a = Environ("Username")
'msgbox a
If a = "stalukder" Then ' Put the user name here. Check the same with the
message box.
Cancel = False
Else
Cancel = True
End If
End Sub

 
Didn't find what you were looking for? Find more on Disable save from Ctrl S Or get search suggestion and latest updates.




Tagged: