Solved

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

Posted on 2014-10-13
11
456 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
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
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 the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

726 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