By adding an XML file (and related entries) to a word document you can add or remove menu items.
This includes the backstage as well as the ribbon interface. The objects in the interface need to be addressed using the Msoobjectname format. Microsoft supply a list of the standard items for most versions of office.
This link gives a list of all the objects in the Schema for Office 2010 (Fluent interface)
https://www.microsoft.com/en-us/download/confirmation.aspx?id=1574, for office 2007 https://www.microsoft.com/en-us/download/details.aspx?id=3582, this one gives a list of all the icons (buttons) used, so if you want to make a new tool but reuse the button you can link to it https://www.microsoft.com/en-us/download/confirmation.aspx?id=11675.
The customui tool is very useful for easily adding or editing the XML it is available from http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/07/7293.aspx and referenced here https://msdn.microsoft.com/en-us/library/cc508991%28office.11%29.aspx#UsingtheCustomUIEditor2_AddingTemplatestotheCustomUIEditor .
However you can open the document with something like 7-zip and then edit the xml with any text editor (such as notepad). But you then need to manually add the correct “relationship” code and it is fairly cryptic to work with.
Adding the XML below will remove the default “send as attachment”, “send as XPS” and “Send as internet fax” options from the word file menu (backstage). It then adds a new button using the same icon as the old save and send one and links it to a macro. The macro and XML can be saved into the normal.dotm template which means this customisation will be current for all documents.
<?xml version="1.0" encoding="UTF-8"?> <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <backstage> <tab idMso="TabShare"> <firstColumn> <taskFormGroup idMso="GroupShare"> <category idMso="Share"> <task idMso="SendUsingEmail"> <group idMso="GroupSendAsAttachment" visible="false"/> <group idMso="GroupSendAsXps" visible="false"/> <group idMso="GroupSendAsInternetFax" visible="false"/> <group id="grpSaveCloseOpenSend" label=" " insertBeforeMso="GroupSendAsAttachment" > <topItems> <button id="btnSCOS" label="Save,Close,Open,Send" style="large" onAction="mySaveCloseOpenSend" imageMso="FileSendAsAttachment" /> </topItems> </group> </task> </category> </taskFormGroup> </firstColumn> </tab> </backstage> </customUI>
This is the VBA code called by the new item added to the “Save/Send” stage. Note that once you define the control As iRibbonControl part it doesnt show as a normal macro. If you dont do that your get “parameter” errors when calling it.
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub mysavecloseopensend(control As IRibbonControl) On Error GoTo MyError1 ActiveDocument.Save On Error GoTo MyError2 Debug.Print ActiveDocument.Name, ActiveDocument.FullName mydocumentname = ActiveDocument.FullName mytext = ActiveDocument.Name + " attachment. " + mydocumentname ActiveDocument.Close Documents.Open FileName:=mydocumentname 'Stop On Error GoTo 0 ActiveDocument.SendForReview Recipients:="email@emaildomain.com", Subject:=mytext, showmessage:=True, includeattachment:=True Exit Sub MyError1: Debug.Print MsgBox(mydocumentname + " Could not be saved, please check the path and try again.", vbCritical, "Error saving document") Exit Sub MyError2: Debug.Print MsgBox(mydocumentname + " Could not be opened, please check the path and try again.", vbCritical, "Error opening document") End Sub