Thursday, December 1, 2011

Create Office 2007 Ribbon UI with Office 2007 Ribbon Editor

Microsoft Office 2007 has introduced a more intuitive UI than the standard drop down menu found in Microsoft Office 2003. The ribbonUI (as it is called) allows users to add custom buttons using standard Office options (i.e. Bold). It also allows users to build a custom ribbonUI calling VBA. Although this is great and all, without a tool to assist you, it can be a very painstaking process. Office 2007 Ribbon Editor is one such tool that allows you to create professional ribbons in little time with limited XML knowledge.



Solution

Download the Program

The application is available directly from the author's website. It is also availabe at Softpedia. Please note that all versions prior to 2.3.0 are labeled as Brazucanet. Due to conflicts of interest all subsequent versions are labeled under LeafCreations.
Features found in the program

Office 2007 Ribbon Editor's main focus is on editing the Ribbon UI for Excel, Word, and PowerPoint. Because these three manage their ribbons directly from XML. Programs like Access require access to Tables.

Beginning with Version 2.3.0 Office 2007 Ribbon Editor introduced a new code editing component that provides new functionality like: Bookmarks, Code Folding, Better Find/Replace. A big plus of this new editing component is the integration of Autocomplete. It allows beginners to develop ribbons faster.

Creating a Custom Ribbon

1) With Office 2007 Ribbon Editor open. Click File > New > Excel Spreadsheet.
2) The program will display a new Excel document with a base XML example. It this time all new documents are created as Macro-Enabled documents.
 3) Click the Save button and name the file tutorial. Open the document in Excel. Below is an example of what is seen in Excel. We will come back to edi


Adding Custom Images

In Office 2003 the use of custom images was available but the process was nerve-racking! Office 2007's Ribbon UI also allows for custom images to be used, but the implementation is so much easier and Office 2007 Ribbon Editor facilates this greatly!


1) Open the tutorial.xlsm document in Office 2007 Ribbon editor. Click on the Images tab.

 2) Click the Add Image(s) button on the Images toolbar. Select an image from the dialog box and click Open. (HINT: Use 16x16 images for the small buttons and 32x32 for the large buttons).

 3) Let's rename the image to myHappyFace. Right-Click on the image and select Edit Image ID.

 4) Edit the name and hit Enter. The result should be as below.

 5)Now comes the fun part. Click on the Code tab to display the XML. Modify line 8 to read
image="myHappyFace"
. Save the file.
6)  Open the file in Excel.

Office 2007 Ribbon Editor also allows you to delete custom images and export images. The images can be displayed as Tiles, Icons, List, or Details.

Validating the XML

To build a ribbon and have it displayed in Excel, Word, or PowerPoint, it must be error free. The XML specifications for the Ribbon are extensive, but thanks to Office 2007 Ribbon Editor, It is only a click away! 

1) With the tutorial.xlsm document open. Click on the Validate XML button on the Code toolbar.
 2) A messagebox is displayed letting us know that all is well.
 3) Now let's modify line 10 by removing the "/>" at the end of the line.

4)  Once again click the Validate XML button on the Code toolbar. Now we have a problem!

  1. Put the "/>" back and validate it again. All is well!
This is a very powerful tool that should be used as many times as needed. Office 2007 Ribbon Editor does Validate the XML when the file is saved.

Creating VBA Callbacks

At is the point of creating a nice ribbon if you cannot do anything with the buttons? Office 2007 allows users to use built in commands or user-defined commands. I am going to show you how to interact with the VBA code.

  1. Once again open the tutorial.xlsm document.
  2. On line 10 you will notice the attribute onAction. The text Callback will be the VBA subroutine name.
 3) Click on the Generate VBA Callback button on the Code toolbar.
 4) Notice that Office 2007 Ribbon Editor changes the focus to the Callbacks tab and the VBA code is generated.
 5) Now click the Save As button on the Callbacks toolbar and save the file as modRibbonFunctions.
6) Close Office 2007 Ribbon Editor and open tutorial.xlsm in Excel.
7) Open VBA Editor (Alt-F11) and import the module.

8)  Add the following code and save the file.
Sub Callback(control As IRibbonControl)
     MsgBox "Hello World!"
End Sub
 
9) Click on the button of your custom ribbon and notice the message box appear!


Using Autocomplete

One of the neat features found in version 2.3 and up is Autocomplete. For beginners this is a life saver because it contains all the ribbon elements and attributes by default, but Office 2007 Ribbon Editor can expose all of the imageMso's and document specific idMso's for ContextualTabs, Tabs, and Groups. It also can include the standard naming conventions used for the different element and attribute ids and controls. The latest version has included an option to include custom images added to the document!
 The Autocomplete features can be enabled or disabled from the Options window.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Total Pageviews

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
|