locked
Gray Out Buttons RRS feed

  • Question

  • Hi Everyone, not sure if correct place to post. I'm trying to gray out buttons specifically the save as and save. In the picture you can see that history is grayed out and even if clicked renders useless. How can I replicate this with save and save as. I am using VBA

    Thanks


    EDIT: Let me ask this instead. I have a button on the screen that serves as a save as button. Can I disable the save and save as features in excel and still make this work?
    Thursday, January 26, 2017 7:56 PM

All replies

  • Hi crusader88,

    Thanks for visiting our forum.

    Then this forum mainly focus on general questions and feed back for Excel. As your query is more related to developing issues involving Excel, I'll move your question to the following MSDN forum for Excel:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thank you for your understanding.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, January 27, 2017 3:22 AM
  • Have a look at the following URL

    http://stackoverflow.com/questions/12264572/how-to-disable-save-and-save-as-using-vba

    Code example at above URL

    Private Sub Workbook_Open()
        Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save As...").Enabled = False
        Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save").Enabled = False
    End Sub

    You will probably need code in the workbook close event to re-enable again by setting to True.


    Regards, OssieMac

    Friday, January 27, 2017 3:24 AM
  • Hi crusader88,

    you need to add XML code and try to set the options for backstage view.

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <backstage>
        <button idMso="FileSave" visible="false"/>
        <button idMso="FileSaveAs" visible="false"/>
        <button idMso="FileOpen" visible="false"/>
        <button idMso="FileClose" visible="false"/>
        <button idMso="ApplicationOptionsDialog" visible="false"/>
        <button idMso="FileExit" visible="false"/>
        <tab idMso="TabInfo" visible="false"/>
        <tab idMso="TabRecent" visible="false"/>
        <tab idMso="TabNew" visible="false"/>
        <tab idMso="TabPrint" visible="false"/>
        <tab idMso="TabShare" visible="false"/>
        <tab idMso="TabHelp" visible="false"/>
        </backstage>
    </customUI>

    if you want to hide then set visible="False".

    if you want to disable then set enabled="False".

    Reference:

    Remove “Save & Send” from File menu in Excel 2010 using custom XML

    so you can try to add this XML file with Custom UI Editor Tool.

    or you can develop a VSTO Excel Workbook project and add a XML Ribbon.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, January 27, 2017 8:30 AM
  • Hi I did see this before and did try this, but it did not work for me. Both still appeared. I put it in the workbook only. I am also using  excel 2016. Thanks
    Friday, January 27, 2017 8:47 PM
  • Hi Deepak, this does a little bit better for me, however the save as still keeps showing. I tried switching between enabled and visible but both don't make it go away. I am using excel 2016. Any ideas?

    EDIT: Let me ask this instead. I have a button on the screen that serves as a save as button. Can I disable the save and save as features in excel and still make this work?

    • Edited by crusader88 Friday, January 27, 2017 11:13 PM
    Friday, January 27, 2017 8:48 PM
  • Hi crusader88,

    This is the only way currently available to manipulate backstage items.

    you can try to refer below approach. in which there is a change in xml may solve your issue.

    <?xml version="1.0" encoding="UTF-8"?>  
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">  
    <commands>  
    <command idMso="FileSaveAs" enabled="false"/>  
    <command idMso="FileSave" enabled="false"/>  
    </commands>  
    </customUI>  
    

    Reference:

    How to disable the "save" and "save as" buttons in Office

    you can refer the visible=false to hide.

    also try to add below line of code above "<backstage>" Tag and try to test.

    <ribbon startFromScratch="true">
    </ribbon>

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 31, 2017 12:25 AM