Simple clear advice in plain English

Hands on: Master the Office 2007 Ribbon

How to make your macros work with Office 2007

Microsoft Office 2007 replaces most of the menus found in earlier versions of Office with a new ribbon control.

From the user’s perspective, the ribbon cannot be customised, but developers have full control. If you have existing Word macros that use menus or toolbars, they usually work in Office 2007, but the implementation is ugly.

Any custom menus get moved to the Add-Ins ribbon tab. What follows is a look at what it takes to revise an existing macro to work properly with the Office 2007 ribbon. The macro integrates media playback into Word so that you can play, pause and navigate an audio file through toolbar buttons or keyboard shortcuts. It’s ideal for transcribing audio, since you can control the sound without reaching for the mouse.

The macro is written in VBA and stored in a Word template. In Word 2007 it works, but the buttons are mixed with those for other compatibility macros on the Add-Ins ribbon.

VBA versus .NET
You may wonder if the VBA macro must be converted to C# or Visual Basic .Net. Fortunately, it’s not necessary, despite Microsoft’s focus on .NET. In fact, it is better to leave it in VBA unless there is a compelling reason to convert it. The Office Ribbon API is Com based, and VBA works well with Com.

Leaving the macro in VBA avoids the overhead of loading the .Net runtime and means that code has no need to cross the Com/.Net boundary.

Converting the template
The first step is to convert the template to the Office 2007 format. Open the old template in Word, and save as a Word macro-enabled template with a .dotm extension. Alternatively, you could start a new macro-enabled template and paste the old VBA code into it. You now have a template in the Open Office XML format.

To customise the ribbon, you need to specify the customisations in an XML file and embed this in the new template according to Microsoft’s XML Packaging specification. Here is an example:

xmlns=”http://
schemas.
microsoft.
com/office
/2006/01/
customui”
onLoad=”This
Document.Ribbon
Loaded”>
startFromScratch=”false”>

Media”>
label=”Word Media”>

Reader Comments

   

Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles

PC help: Change colour in Excel

How to adjust shades and styles in Excel styles

Hands on: Mini-macros for multi-uses

Use macros to perform your most frequent program commands

Question & Answer

Q.Why are some of the keys on my keyboard doing strange...

> Read the answer

Q.Is my phone’s Bluetooth any use?

> Read the answer

Q.Can I switch boot drives so that I can work on older...

> Read the answer

Best deals on the web

img

Samsung RV520-A07

£359.98- Buy it now

img

Acer Aspire 5750G (LX.RXP02.019)

£399.99- Buy it now

img

Apple MacBook Pro (MD313B/A)

£904.37- Buy it now

Latest issue & subscription deals

Poll

Are you concerned about viruses that target mobile phones?

Jargon Buster

Computing terms explained in plain English

Virtual drive

A set of files seen by Windows as a separate hard disk.

Great shopping deals from Computeractive