How do you disable “Save and send” in Excel 2010 (in the File ribbon (called backstage in Office 2010)?

前端 未结 3 2004
别那么骄傲
别那么骄傲 2020-12-21 18:06

I have the following VBA marco running in Excel 2003, it blocks the Save, Save as, Save Workspace, Send To menus but I now need to do the same but for Excel 2010 ?

相关标签:
3条回答
  • 2020-12-21 18:20

    I have tried commands listed below and these are disabling the save and send menu in Excel 2010:

    Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Send To").Enabled = False
    Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save & Send").Enabled = False
    
    0 讨论(0)
  • For Ribbon UI example/documentation from Microsoft, here. They will recommend you use the CustomUI Editor.

    Open your file (which must be an Excel 2007+ file extension like XLSX, XLSM, XLAM, etc) in the CustomUI Editor. Then use this XML in the editor:

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <backstage>
        <tab idMso="TabShare" visible="false" enabled="false">
        </tab>
    </backstage>
    </customUI>
    

    Save the file, and close the CustomUI Editor.

    Then, open your file. Go to the File/Backstage view and you should see that the Save and Send tab has been removed:

    screenshot of disabled TabShare

    Note: This has disabled the entire "Save & Send" tab from the backstage view. It should be possible using XML to fine-tune this, i.e., to enable the tab, but disable specific controls therein (e.g., maybe you only want to disable Send as Attachment but you want to leave the other options enabled, etc.) but I haven't quite worked out the XML hierarchy to disable only the specific Send As Attachment control.

    Hope this helps!

    Update from Comments

    1) The user will find "normal" functionality when this file is closed, or when another file is Active. The UI customization only applies to the file which contains the Custom UI XML parts, so if you have multiple files open, only this file will be affected by the disabled Save & Send tab.

    2) Unfortunately, this is not compatible with Excel 2003 or prior. The CustomUI/XML is not a part of the legacy XLS files, and as such, cannot be implemented in these versions. For 2003/prior versions of Excel, you will have to use the legacy CommandBars which can be controlled through VBA. It is relatively easy to put some VBA code that will check which version of Excel, and run a subroutine to disable certain CommandBar/Controls only if the user is in 2003 or prior versions.

    If you try to save this down to an XLS file, you will receive a warning, indicating that this feature is incompatible with the file type:

    CustomUI XML not compatible with XLS files

    Additionally, you cannot open an XLS file in the CustomUI Editor.

    0 讨论(0)
  • 2020-12-21 18:39

    This commands worked for me

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <commands>
        <command idMso="TabShare" enabled="false"/>
    </commands> 
    </customUI>
    
    0 讨论(0)
提交回复
热议问题