Developing an add-in for multiple versions of Office (Mary Lee)

Theoretically, you can develop an add-in for multiple versions of Microsoft Office by catering to the lowest common denominator. This means if you use an Excel 2003 add-in template in Visual Studio 2008, you would be able to develop and debug this with Excel 2007. However if you try this, you may meet these error messages: “You cannot debug or run this project, because the required version of the Microsoft Office application is not installed.”, followed by “Unable to start debugging.”

You can develop an Office 2003 add-in but use the 2007 Microsoft Office system for debugging. The following procedure demonstrates how to update your Visual Studio debugging options to use Microsoft Excel 2007 to debug an add-in targetting Microsoft Excel 2003.

1. On the Project menu, click on ProjectName Properties.

2. Click on the Debug tab.

3. In the Start Action pane, click the Start external program radio button.

4. Click the file browser button and navigate to %ProgramFiles%Microsoft OfficeOffice12.

5. Choose Excel.exe and click Open.

6. Press F5 to debug your add-in.

This procedure works because the .NET Framework runtime loads the 2007 Microsoft Office version of the primary interop assembly, even though the add-in was developed with the Microsoft Office 2003 PIA. For more information, see Office Primary Interop Assemblies.

Before you use a Microsoft Office 2003 template, consider the impact on your project. Because you created your project with an Excel 2003 add-in template, you can now develop with the .NET Framework 2.0. However, this means that you cannot use new features in Visual Studio 2008 that depend on .NET Framework 3.5.

For additional information, see Andrew Whitechapel’s blog entry Can you build one add-in for multiple versions of Office? and the MSDN Library documentation Creating Solutions for Multiple Versions of Microsoft Office.

Mary Lee, programming writer.