Step 3: Copy the Custom XML Markup File to the Document Package
You're now ready to take the custom XML markup file that you created in step 2 and add it to the document package. Begin by renaming the document or template so that you add .zip to the end of the filename. When Windows asks you to confirm the extension change, click Yes. You can now click and drag the custom XML file and then drop it on the zip container to add it to the document package.
At this point, the custom XML is in the package, but the Office application doesn't know what to do with it. You now need to define a relationship that points the Office application to the new XML part. Open the zip container and then open the _rels folder. You need to get the .rels file out of the container so that you can edit it, and then return it when you're finished. Here's one method that takes advantage of the fact that you have the document package in its own folder:
- Right-click the .rels file and then click Copy.
- Return to the folder that contains the document package.
- Right-click the folder and then click Paste.
- Right-click the copy of the .rels file and then click Edit to open it in Notepad.
- Make your edits (as described after these steps), save the file, and then exit Notepad.
- Right-click the copy of the .rels file and then click Copy.
- Open the zip container and then open the _rels folder.
- Right-click the folder and then click Paste.
- When Windows asks you to confirm, click Copy and Replace (in Vista) or Yes (in XP).
When you have the .rels file open for editing, you need to add a new <Relationship> element that points to your custom XML file in the container. Insert this element between the <Relationships> and </Relationships> elements, but not within any existing <Relationship> elements. Here's the general format:
<Relationship Id="ID" Type="http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" Target="CustomXMLFile"/>
ID
A string identifier that's unique in the .rels file.
CustomXMLFile
The name of the file that contains the custom XML markup.
Here's an example:
<Relationship Id="MyRibbonID" Type="http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" Target="MyRibbon.xml"/>
In this tutorial:
- Customizing the Office 2007 Ribbon
- Understanding Ribbon Extensibility
- Extending the Ribbon: An Example
- Step 1: Create a Macro-Enabled Office Document or Template
- Step 2: Create a Text File and Add the Custom XML Markup
- Step 3: Copy the Custom XML Markup File to the Document Package
- Step 4: Rename and Open the Document
- Hiding the Built-In Ribbon
- Creating Custom Tabs
- Customizing an Existing Tab
- Creating Custom Groups
- Customizing an Existing Group