Solved

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

Posted on 2014-10-13
11
332 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:
Iammontoya earned 350 total points
Comment Utility
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
Comment Utility
@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
Comment Utility
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
Comment Utility
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
Comment Utility
Ah, my answer was for lammontoya, just to be clear.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:bthouin
Comment Utility
@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
Comment Utility
yes,
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
Comment Utility
it works in 2013
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks both of you for helping.

Bernard
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

763 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

11 Experts available now in Live!

Get 1:1 Help Now