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
Solved

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

Posted on 2014-10-13
11
417 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 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
0
 
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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

Expert Comment

by:ProfessorJimJam
ID: 40377467
yes,
0
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40377468
it works in 2013
0
 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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.

809 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