wordpress hit counter
Custom UI Editor Tool - OpenXML Developer - Blog - OpenXML Developer

Custom UI Editor Tool

Blog

Samples, Demos, and Reference Articles

Custom UI Editor Tool

Rate This
  • Comments 31

LASTEST VERSION OF THE CUSTOM UI EDITOR - updated to work with the RTM build of Office 2007 and Beta build of Office 2010 - ATTACHED TO THIS POST

The 2007 Microsoft Office System has an all-new "ribbon" interface which developers can customize in many ways. One of the ways to extend the ribbon is to insert an XML part into an Office Open XML document that defines your custom UI. With this approach, you can add new groups and controls, hide existing ribbon elements, and define callbacks to handlers that you write in managed code.

The XML part is not part of the Open XML format itself but could be added to any XML document by using a new namespace. The Open XML file formats are fully extensible, so applications can store information like workflow, metadata, custom XML, or even custom UI behaviors in a document that aren't necessarily tied to the document content.

Adding your custom-UI part to an Office Open XML document requires that you create a folder within the package, drop in your part, then define a relationship to the new part. For more information about how it all works, check out this technical artice or the "Extending the Office 2007 UI with a Custom Ribbon" screencast on this page.

custom UI editor

Attached to this post is a great utility for working with ribbon customizations stored in Office Open XML documents: Trang Luu's custom UI editor. It's a Windows tool that automates the process of putting your custom UI part into the package and defining a relationship to it: that's all handled by a single mouse click.

You open an existing document with File/Open, then enter your custom UI XML into the main edit box. (Click the image to the right for a full screen shot.) Other options include inserting icons for your custom control, generating callbacks, and validating your custom XML.

Install the tool and try it out, and if you have any questions about using it you can post them right here.

Attachment: OfficeCustomUIEditorSetup.zip
  • Looks great, a fantastic idea, but it doesn't work for me. I followed the instructions to the letter, but the new tab doesn't appear in the document.
  • This version doesn't seem to work for me either. The previous version worked great.
  • Excellent tool. Worked gr8 by me. Note that any mistake will cause the new tab not to appear. The best way is to check each new line of code piecemeal, i.e. add a tab and then check it in Office, add a group and check it, etc.
  • The new tool did not work for me either, but I found a workaround.  When you add a new UI part you will notice that it is named customUI14.xml on the left hand side.  If you were using the schema with dates 2006/01 you will  need to add another UI part and it will be named customUI.xml.  I removed the initial UI part and used the correctly named customUI.xml one and I was fine going forward.
  • The sample xml templates provided with the tool are targeted only for Office 2010 documents. Adding one more set of sample xml files for Office 2007 would help avoid ambiguity and namespace mismatch errors that lot of users currently face.
    Also, the screenshot of the tool's UI needs updatiion :)
  • Would be great if you could release the source under GPL licence or something similar. I'm sure there are a few people who would be willing to add more functionality to the editor! Such as a Find function :)
  • I will also point out that there is a bug in this. If the "Samples" folder is missing the program will crash when expanding the Insert menu.
  • Windows 7 64bit Ultimate. Installed 32 bit Office 2010 RC.
    Installed latest Custom UI Editor.
    Open / Sample / Excel...
    "Corrupted data..."

    Insert Sample XML,
    "Unhandled exception..."
    for any data sample.

    Seems like the latest RC breaks the program.
  • I also downloaded and just installed the lasted attachment.
    If you start the application, and try to insert sample XML you will get an error.
    In my case I fixed this by opening an Excel workbook first.  Then the sample XML insertion works fine.

    The Insert Sample XML menu item should be disabled until there is something valid to insert it into.
  • Opening an existing Excel workbook, I inserted some sample XML, then overwrote it with the following:

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
     <ribbon startFromScratch="false" >
       <tabs>
         <tab id="CustomTab" label="My Tab" >
           <group id="SimpleControls" label="My Group">
             <toggleButton id="ToggleButton1"
               size="large" label="Large Toggle Button"/>
             <button id="Button2" label="My Button " />
             <comboBox id="Combo1" label="ComboBox">
               <item id="Month1" label="January" />
               <item id="Month2" label="February" />
               <item id="Month3" label="March" />
             </comboBox>
           </group>
         </tab>
       </tabs>
     </ribbon>
    </customUI>

    This code was modified from: http://msdn.microsoft.com/en-us/aa338202.aspx so that the new tab added "MyTab" is appended to the existing tabs rather than replacing them.

    The only caveat with the editor is that you have to close the workbook to save edits, then reopen it.   But given how much tedium this removes, this is a small inconvenience.

    Thanks Trang!!
  • First, I don't even understand what XML is.  I am just trying to find a way to create icons that are assigned to macros that I put on the quick launch bar of Word 2007.  I followed the article (and one from http://msdn.microsoft.com/en-us/library/cc501317%28office.11%29.aspx) and the suggestions here, and got it to work.  Only problem is, that as soon as I close the sample.docm, that I opened from the Custom UI editor, the neat icons I made disappear in all the .docx windows (Am I making sense?).

    It may seem like an ignorant question (and please dumb down the answer for me!) but can I make the Icons I loaded into the Custom UI editor stick to non-.docm's?  Maybe this isn't the right place to even post this Q, that's how clueless I am!
  • @  DannyBones

    "can I make the Icons I loaded into the Custom UI editor stick to non-.docm's? "

    The way i understand it, no!

    Office 2007 does not allow such things in DocX files. You would have to save them as DocM files. If you try and save a file which had code in as ".docx" then I think Word2007 warns you of this.

  • Thank you for the tutorial.
  • Thanks. It would be nice if it would open the document specified in the command line, so we can add this utility to an "Open With" action for Office documents.
  • For the most part, this utility works great, but I was unable to use my own icons.  If I use the imageMso = "HappyFace", those icons appear in my tabs, but If I use image = "myicon.png" and insert the icon into the file, it only appears as a blank in the tab when I open a file.  I've tried all the various flavors of icons, to no avail, any ideas?
Page 1 of 3 (31 items) 123