Solved

Excel 2013: how do I hide/delete "Save" and "Save as" menu items in the File "menu"

Posted on 2014-10-13
11
356 Views
Last Modified: 2014-10-15
Hi

I have a Excel template with code (.xltm) which when used creates an .xlsm Excel. In that one, I'd like to block the user from using the Save and Save As menu points of the File "menu", because I have my own routine to save with a given name in a give directory when the user closes the Excel.

I have been fighting without results with what I found so far here and in the internet in terms of VBA code. It all seems to apply to older versions of Excel, and the only things that did not generate an outright runtime error are not working either. They are:

1) Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save").Visible = False

2) Private Sub Hide_menu_options()
    Dim CmdBar     As CommandBar
    Dim Cmb        As CommandBarControl
    Set CmdBar = Application.CommandBars("Worksheet Menu Bar")
    For Each Cmb In CmdBar.Controls
        Select Case Cmb.Caption
            Case "&File"
                Debug.Print Cmb.Caption
                Cmb.Visible = False
            Case Else
        End Select
    Next
 End Sub

Can anyone give me something that works or tell me what's wrong with the above in Excel 2013 ?

Thanks for help
Bernard
0
Comment
Question by:bthouin
  • 5
  • 5
11 Comments
 
LVL 19

Accepted Solution

by:
Montoya earned 350 total points
ID: 40377290
Have this saved in my archives: (change what doesnt apply)


Put this in the ThisWorkbook module:

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = True
End Sub


Then in the procedure assigned to your button do this:

Code:
Application.EnableEvents = False
'Your code to save
Application.EnableEvents = True
0
 
LVL 25

Assisted Solution

by:ProfessorJimJam
ProfessorJimJam earned 150 total points
ID: 40377390
@bthouin  

please find attached.  you can do this without Macro.

since experts exchange forum, do not allow uploading files with extention of xltm , i renamed it with xlsx and once you download it in your machine, then rename it back from .xlsx to  .xltm


open the file and the Save and SaveAs is grayed out.
Book1.xlsx
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40377407
following to my comment above.

you might ask the question, how would you be able to do it by yourself.

easy solution  Andy Pope has a free excel add-in Ribbon Editor. you can twist and disable as many icons and functions as you want.  here is the link.

http://www.andypope.info/vba/ribboneditor_2010.htm
0
 
LVL 1

Author Comment

by:bthouin
ID: 40377420
Yep, that code I've seen already a couple of times, but I never dared using it, 'cause I thought it could interfere with my code for saving, because that code is not triggered by a button, but by the user closing the Excel by clicking on the "x" at the top right, which triggers the BeforeClose event, which is where I have my code for saving.

So, will your code work in that setup ?
0
 
LVL 1

Author Comment

by:bthouin
ID: 40377426
Ah, my answer was for lammontoya, just to be clear.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:bthouin
ID: 40377465
@ProfessorJimJam

I opened your xltm in Excel 2013, it disabled Save, but not Save As. And Andy's add-in says everywhere Office 2010, so will it really work on Excel 2013 ?
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40377467
yes,
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40377468
it works in 2013
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40377469
i forgot to disable saveas.  do you want me to disable save as as well and send to you. or you rather do it your self by Andy;'s addin?
0
 
LVL 1

Author Comment

by:bthouin
ID: 40377555
I'll do it myself, thanks. I have implemented the simple approach by lammontoya, I will test it tomorrow. If it works, it's probably sufficient for my purposes. If if doesn't, or if I have further requirements, I'll have a closer look at Andy's addin.

I'll keep you all posted
Bernard
0
 
LVL 1

Author Comment

by:bthouin
ID: 40381726
Thanks both of you for helping.

Bernard
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now