Creating item templates for Ribbon customizations to use in Visual Studio
Despite my passion for all things related to code, I've always had a soft spot for UI that is exciting both in its "coolness" factor and visual appeal. Along those lines, one of my favorite new features in Access 2007 is Ribbon Extensibility. Writing the XML for a customization can be a bit of a bear, so here is a tip for making this easier.
Before getting started with creating your own customizations, there are a few things you should have:
With Visual Studio or one of the Express editions installed, you can create new file item templates that have portions of the XML of a customization already written. This involves creating the relevant XML and saving it to a particular directory, then modifying a file used by Visual Studio to tell it about the new file that you're adding.
For example, let's say that you wanted to create a new Ribbon customization that started with a blank Ribbon with a single tab with a single group. The XML for the customization might look something like:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="true">
<tabs>
<tab id="tab1">
<group id="group1">
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Create a new XML file that uses this customization and save it as RibbonTabAndGroup.xml in the following location: %PROGRAMFILES%Microsoft Visual Studio 8\Common7\IDE\NewFileItems. Change the path to Visual Studio/Visual Web Developer Express if needed.
Next, modify the NewFileItems.vsdir file in the NewFileItems directory to add the new item. For details about this file, check out this article in MSDN. Add the following record to the .vsdir file as the last line of the file.
RibbonTabAndGroup.xml| |RibbonX - Tab and Group|80|Ribbon customization for a blank Ribbon with one tab and one group|#14207|0|0|RibbonXTabGroup.xml
After you add the record to the file, close and re-open Visual Studio. Click the File menu, then choose New and choose File... You should now see the new item in the New File dialog as shown here.
Rob Cooper is a Test Lead at Microsoft working on Microsoft Access. He started at Microsoft in 1998 working in Access product support in Charlotte, NC and then moved to Redmond to join the test team in 2001. For Access 2007, Rob worked on the new Grouping Pane for Reports, and security features such as Database Encryption and Disabled Mode. He is also a co-author on Expert Access 2007 Programming and Access 2007 VBA Programmer's Reference, both published by Wrox.
Rob also spends time on www.utteraccess.com reading and answering questions.