Pieter van der Westhuizen

Programming for Office 2010 on Windows 8 with Visual Studio 2012

If you’ve been following any IT related news lately you would’ve noticed that Microsoft has a number of new products and ideas up their sleeves. Last week we’ve seen their tablet offering, Microsoft Surface, announced. Windows 8 is close to release as well as Visual Studio 2012 and Office 2013 (or Office 15?) will be released in 2013.

First off, DON’T PANIC

No, this is not an episode of The Hitchhiker’s Guide to the Galaxy, but we are going to be discussing Windows 8 and how it will influence us as Office developers.

Windows 8 desktop

When you first start using Windows 8 it does give you a warm and friendly feeling, until you’re not able to switch between applications and suddenly find it hard to breath. But, I have to admit, after messing around with Windows 8 and getting used to the way the new Metro start menu works and realizing that, deep down Microsoft loves us and everything is going to be all right, I really liked it.

Where does Office 2010 go?

In short, Office 2010 and traditional desktop applications are not going anywhere, at least not for now. In Windows 8 the traditional desktop is essentially just another app and it is similar to your current Windows 7 desktop albeit without the traditional Start button.

You would still be able to install older versions of Microsoft Office on Windows 8, it will simply run in desktop mode giving you the same experience as Windows 7.

Hands on with Visual Studio 2012 and Add-in Express

Despite the fact that Windows 8 implies using Office 15, we have decided to install Office 2010 and see how you can get it to work with Add-in Express based add-ins. We’ll be using Visual Studio 2012 RC and the up and coming release of Add-in Express for Office and net, all installed on Windows 8 Release Preview.

When you start Visual Studio 2012 you are greeted with a somewhat familiar sight, the overall layout of Visual Studio 2012 has not changed that much, we still have our Solution Explorer and all the other known windows.

Visual Studio 2012

For some bizarre reason, all the menus are capitalized, if you can’t get used to it, read how to change it here.

To create a new Add-in Express project, select New > Project… from the File menu. You’ll find that all the Add-in Express project templates are in their familiar place under Other Project Types > Extensibility.

Creating a new Add-in Express project

We’ll create a new Add-in Express COM Add-in project by selecting its project template and clicking OK. The New Microsoft Office COM Add-in wizard appears, with a new Metro-inspired look! Select your language of choice (C# for this sample) and the minimum supported Office version and click Next.

Select C# as the programming language and Office 2010 as the minimum supported Office version

To create a shared add-in that will be accessible from both Excel and Outlook, tick Microsoft Excel and Microsoft Outlook on the next screen.

Choose Microsoft Excel and Microsoft Outlook as supported applications

When you have finished the wizard, you’ll see a Visual Studio window indicating that it is busy creating your add-in project.

Visual Studio 2012 creating your project

After the above step was completed, you’ll see all the familiar items in the Solution Explorer, albeit with new monotone icons.

Solution Explorer

Double-click on the AddinModule.cs class to open its designer. You’ll notice that the designer is familiar.

Add-in module at design-time

For this Office 2010 add-in example, we’ll create a simple shared Ribbon Tab for Outlook and Excel.

Add a custom ribbon by clicking on the ADXRibbonTab button on the toolbar.

Adding a custom ribbon tab

We can then design our ribbon tab using the built-in designer. We’ll add two ribbon groups; one will only be visible in Outlook and the other only in Excel. Do this by specifying the Ribbons property on both the groups to OutlookExplorer and ExcelWorkbook.

Adding two groups to your ribbon tab using visual designer

Make sure you’re running Visual Studio as an administrator and build and register your project.

Register your project

Next, start Microsoft Excel. In Windows 8, you’ll find it under the Microsoft Office group.

Starting Excel 2010 in Windows 8

Your add-in running on Windows 8 with Office 2010

If all went well, you should see the “My Custom Ribbon Tab” ribbon tab in Excel 2010 with only the Excel group visible.

A custom ribbon tab in Excel 2010 with only the Excel group visible

Next, start Outlook 2010 and you’ll see the Outlook group in the Outlook Explorer window.

A custom ribbon tab in the Outlook 2010 Explorer window

There you have it! Our Office 2010 Add-in will still work in Windows 8, so embrace the changes that are coming, it will give developers a whole new world of opportunities.

Thank you for reading. Until next time, keep coding!

Post a comment

Have any questions? Ask us right now!