Solved

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

Posted on 2014-10-13
11
560 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 26

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
1
 
LVL 26

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 ?
1
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40377467
yes,
0
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40377468
it works in 2013
1
 
LVL 26

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

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;…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
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…

696 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