Create Custom Tabs in the Office 2010 Backstage View

Office Quick Note banner

Getting Started with Office 2010 Fluent UI Customization: Learn how to create custom tabs on the Office 2010Backstage view user interface.

Applies to: Excel 2010 | Office 2010 | PowerPoint 2010 | Word 2010

In this article
Create the Documents
Add XML to the Document to Create the Tab
Add Code to Give the Command Functionality
Test the Solution
Next Steps

Published:   August 2010

Provided by:    Frank Rice, Microsoft Corporation

In this exercise, you create a custom tab, group, and button on the Backstage view user interface (UI). The button loads a template instance into a Microsoft Word 2010 document. To complete this task, you must do the following:

  • Create the Documents

  • Add XML to the Document to Create the Tab

  • Add Code to Give the Command Functionality

  • Test the Solution

This exercise uses the Custom UI Editor to edit the test document. Find the tool at OpenXMLDeveloper.org

Create the Documents

In this task, you create a test document in Word 2010 that you update with the XML to create the custom tab. You also download the resume template that is loaded when you click the button contained on the custom tab.

To create the Word 2010 documents

  1. Start Word 2010 and on the Quick Access Toolbar, click Save.

  2. In the File name box, type Custom Tab Sample, and in the Save as type drop-down list, click Word Macro-Enabled Document (*.docm), and then click Save.

  3. Next, you create the document that is loaded into the test document when you click the fast command. In the current document, click the File tab, and then click New.

  4. Scroll down and then click Resumes and CVs.

  5. In the Basic Resumes folder, click any resume template, and then click Download.

  6. Click the File tab, and then click Save As.

  7. In the File name box, type MyResume. In the Save as type drop-down list, click Word Template (*dotx), and then click Save.

  8. Close the document.

Add XML to the Document to Create the Tab

In this task, you use the Custom UI Editor to add XML markup code to the document that creates the custom tab, group, and button.

To add XML to the test document

  1. Start the Custom UI Editor, and then on the File menu, click Open.

  2. Navigate to the test document that you create previously, and then click Open.

  3. On the Insert menu, click Office 2010 Custom UI Part.

  4. On the navigation pane, click the customUI14.xml.

  5. In the code window, add the following code.

    <customUI xmlns="https://schemas.microsoft.com/office/2009/07/customui">
       <backstage>
          <tab id="customTab" label="Sample Tab">
             <firstColumn>
                 <group id="customGroup" label="Custom Group">
                    <topItems>
                       <button id="customButton" label=" Load &amp;&amp; Return" imageMso="BevelShapeGallery" onAction="OnAction" isDefinitive="true" />
                    </topItems>
                 </group>
              </firstColumn>
           </tab>
       </backstage>
    </customUI>
    

    This code has several actions occurring. First, it adds a custom tab to the Backstage view. It also adds a button to a custom group to the tab. Notice the hierarchy of controls necessary to add the group and button. The code also shows how to include ampersands into the label name by escaping the &amp; token with another &amp; token. The button uses a built-in image as denoted by the imageMso attribute. The onAction attribute specifies the macro that is executed when you click the button. And finally, setting the isDefinitive attribute to true closes the Backstage view and returns you to the document when you click the button.

  6. On the toolbar, click Validate and correct any errors.

  7. Save and then close the Custom UI Editor.

Add Code to Give the Command Functionality

In this task, you add Microsoft Visual Basic for Applications (VBA) code to the test document that loads an instance of the resume template.

To add VBA code to the test document

  1. Open the test document, and then on the Developer tab, click Visual Basic.

  2. On the Insert menu, click Module.

  3. Add the following code in the code window.

    Sub OnAction(control As IRibbonControl)
        Dim wdApp As Word.Application
    
        Set wdApp = GetObject(, "Word.Application")
        wdApp.Documents.Open FileName:="C:\<your path here>\MyResume.dotx", ReadOnly:=True, AddtoRecentFiles:=False
    End Sub
    
  4. Close the VBA editor.

Test the Solution

In this task, you test the solution by clicking the fast command button and uploading the resume template.

To upload the resume document

  1. Click the File tab, click Sample Tab, and then click Load & Return as shown in Figure 1.

    Figure 1. Load & Return command

    Load and Return command

    The Backstage view closes and the resume is loaded into an instance of the template document.

  2. Close the document.

Next Steps