Editor - Document Level


Excel Workbook with a Custom Ribbon

This ribbon customisation will only be visible when this particular workbook is open.
Create a new workbook and save it as a macro-enabled workbook (WorkbookRibbon-Editor.xlsm)
Open the Custom UI Editor by double clicking on the following file:

C:\Program Files\CustomUIEditor\CustomUIEditor.exe 
alt text

Open the Workbook

Select (File > Open) and browse to your WorkbookRibbon-Editor.xlsm file.

alt text

Add the customUI file

Before we can add the ribbon XML to this file you need to add the corresponding customui file.
It is this xml file that will contain the ribbon XML.
Right click on the entry and choose one of the following
Office 2010 Custom UI Part - Select this one if you are using Office 2010 or later (inserts customUI14.xml)
Office 2007 Custom UI Part - Select this one if you are using Office 2007 (inserts customUI.xml)

alt text

Add the Ribbon XML

Copy and paste the xml tags below into the window

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> 
  <ribbon startFromScratch="true">
    <tabs>
      <tab id="CustomTab" label="My Tab">
        <group id="SimpleControls" label="My Group">
          <button id="Button1" imageMso="HappyFace" size="large"
                  label="Large Button"
                  screentip="my long description"
                  onAction="ThisWorkbook.MyMacro"/>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

The tags will be formatted automatically once they have been pasted in.

alt text

Press the Validate button on the toolbar to check the XML is well formed.

alt text

Save Changes and Open

Select (File > Save) and close the CustomUI Editor.
Open the WorkbookRibbon-Editor.xlsm file

alt text

Running a Macro

When you click on the button you will see this message appear.

alt text

This is telling us that we have not linked an event handler to the pressing of the button.
Open the Visual Basic Editor and add the following code to the ThisWorkbook code module.

Public Sub MyMacro(ByRef control As Office.IRibbonControl) 
   Call MsgBox("Hello large button")
End Sub
alt text

Save the workbook and press the button.

alt text

See All Tabs

If you would like to see all your existing tabs then you need to change the startFromScratch property.
Change the following line at the top of the XML:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> 
  <ribbon startFromScratch="false">

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext