ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disabling 'File/Save' Menu Item (https://www.excelbanter.com/excel-programming/327246-disabling-file-save-menu-item.html)

Paige

Disabling 'File/Save' Menu Item
 
I would like to disable the File/Save menu item once a workbook is opened,
forcing a person to save the file under another name. I have code (see
below) to disable the File/Save As menu item, but cannot make one work for
disabling just File/Save. Can anyone assist with this?

Sub DisableSaveAsMenuItem()
With CommandBars("Worksheet Menu Bar")
With .Controls("File")
.Controls("Save As....").Enabled = False
End With
End With
End Sub

Fredrik Wahlgren

Disabling 'File/Save' Menu Item
 

"Paige" wrote in message
...
I would like to disable the File/Save menu item once a workbook is opened,
forcing a person to save the file under another name. I have code (see
below) to disable the File/Save As menu item, but cannot make one work for
disabling just File/Save. Can anyone assist with this?

Sub DisableSaveAsMenuItem()
With CommandBars("Worksheet Menu Bar")
With .Controls("File")
.Controls("Save As....").Enabled = False
End With
End With
End Sub


Try this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Not SaveAsUI Then
Cancel = True
End If
End Sub

It will prevent File|Save but not File|Save As. Is this hwat you want? You
say that you want to force tthe user to save under a different name. I don't
understand why your code tries to disable Save As.

/Fredrik



Jim Thomlinson[_3_]

Disabling 'File/Save' Menu Item
 
Why not just create the file as a template (.xlt) file at which point the
user can not save over the original and is forced to Save As. I see the
current method as being problematic. The Save feature would be gone for all
open spreadsheets. Not to mention you will need to get rid of Ctrl + S. If
the program crashes unexpectadly all is lost...

HTH

"Paige" wrote:

I would like to disable the File/Save menu item once a workbook is opened,
forcing a person to save the file under another name. I have code (see
below) to disable the File/Save As menu item, but cannot make one work for
disabling just File/Save. Can anyone assist with this?

Sub DisableSaveAsMenuItem()
With CommandBars("Worksheet Menu Bar")
With .Controls("File")
.Controls("Save As....").Enabled = False
End With
End With
End Sub


Jim Thomlinson[_3_]

Disabling 'File/Save' Menu Item
 
I like this solution, but this is going to require this workbook to be saved
as something different every time you want to save. (On the other hand that
is what Paige asked for). I have always liked your solutions so I was
wondering if you had a cool way around this... :)

"Fredrik Wahlgren" wrote:


"Paige" wrote in message
...
I would like to disable the File/Save menu item once a workbook is opened,
forcing a person to save the file under another name. I have code (see
below) to disable the File/Save As menu item, but cannot make one work for
disabling just File/Save. Can anyone assist with this?

Sub DisableSaveAsMenuItem()
With CommandBars("Worksheet Menu Bar")
With .Controls("File")
.Controls("Save As....").Enabled = False
End With
End With
End Sub


Try this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Not SaveAsUI Then
Cancel = True
End If
End Sub

It will prevent File|Save but not File|Save As. Is this hwat you want? You
say that you want to force tthe user to save under a different name. I don't
understand why your code tries to disable Save As.

/Fredrik




Fredrik Wahlgren

Disabling 'File/Save' Menu Item
 

"Jim Thomlinson" wrote in message
...
I like this solution, but this is going to require this workbook to be

saved
as something different every time you want to save. (On the other hand

that
is what Paige asked for). I have always liked your solutions so I was
wondering if you had a cool way around this... :)


Thanks! Well, I guess Paige could create a hidden command with this code

Application.EnableEvents = False
ActiveWorkbook.Save
Application.EnableEvents = True

/Fredrik



Paige

Disabling 'File/Save' Menu Item
 
Thanks, guys. I see what you are saying re being problematic...lots of good
suggestions on how to code or saving as a template. I'll work with these and
see what ends up working best for this particular worksheet. Appreciate your
quick responses - have a great day!!!.....Paige

"Fredrik Wahlgren" wrote:


"Jim Thomlinson" wrote in message
...
I like this solution, but this is going to require this workbook to be

saved
as something different every time you want to save. (On the other hand

that
is what Paige asked for). I have always liked your solutions so I was
wondering if you had a cool way around this... :)


Thanks! Well, I guess Paige could create a hidden command with this code

Application.EnableEvents = False
ActiveWorkbook.Save
Application.EnableEvents = True

/Fredrik




Paige

Disabling 'File/Save' Menu Item
 
PS to Fredrik - you said "You say that you want to force the user to save
under a different name. I don't understand why your code tries to disable
Save As."...that was just some code I found to disable SaveAs and was trying
to change it around to disable Save. You're right, I want to disable Save,
so your code was correct. Thanks again - Paige


"Fredrik Wahlgren" wrote:


"Paige" wrote in message
...
I would like to disable the File/Save menu item once a workbook is opened,
forcing a person to save the file under another name. I have code (see
below) to disable the File/Save As menu item, but cannot make one work for
disabling just File/Save. Can anyone assist with this?

Sub DisableSaveAsMenuItem()
With CommandBars("Worksheet Menu Bar")
With .Controls("File")
.Controls("Save As....").Enabled = False
End With
End With
End Sub


Try this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Not SaveAsUI Then
Cancel = True
End If
End Sub

It will prevent File|Save but not File|Save As. Is this hwat you want? You
say that you want to force tthe user to save under a different name. I don't
understand why your code tries to disable Save As.

/Fredrik




Fredrik Wahlgren

Disabling 'File/Save' Menu Item
 

"Paige" wrote in message
...
PS to Fredrik - you said "You say that you want to force the user to save
under a different name. I don't understand why your code tries to disable
Save As."...that was just some code I found to disable SaveAs and was

trying
to change it around to disable Save. You're right, I want to disable

Save,
so your code was correct. Thanks again - Paige



Ahh... That's what I suspected. I'm glad I could help.

/Fredrik



Paige

Disabling 'File/Save' Menu Item
 
Glad you could help also!!!! Thanks for sharing your wisdom and knowledge -
very much appreciated. Have a good one...

"Fredrik Wahlgren" wrote:


"Paige" wrote in message
...
PS to Fredrik - you said "You say that you want to force the user to save
under a different name. I don't understand why your code tries to disable
Save As."...that was just some code I found to disable SaveAs and was

trying
to change it around to disable Save. You're right, I want to disable

Save,
so your code was correct. Thanks again - Paige



Ahh... That's what I suspected. I'm glad I could help.

/Fredrik





All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com