Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert an Excel 2010 addin to a 2007 addin (both VSTO)

I am currently working on an Excel 2010 add-in which formerly was an Excel 2007 add-in. Somewhere in the process of switching computers, the add-in was converted i think.

Some of my customers stated that the add-in wasn't working on Excel 2007 anymore so I tried to debug it in a VirtualBox with Excel 2007 and Visual Studio 2010 installed.

Now I get the Error Message:

You cannot debug or run this project, because the required version of the Microsft Office application is not installed.

I started a new Excel 2007 add-in project and tried to find what the differences are and came up with the idea that it somewhat has to do with the dll's so I changed my 2010 addin until it looked like an 2007 addin.

I still get the error message stating that my project can't be debugged.

Is there anything I could've forgotten to change.

Writing a completely new addin is unfortunately not an option.

These questions haven't helped me so far:

  1. Excel Addin that works on Excel 2007 and 2010
  2. Deploying Office 2010 addin
like image 963
Bongo Avatar asked Sep 25 '12 13:09

Bongo


People also ask

What is a VSTO addin?

Visual Studio Tools for Office (VSTO) is a set of development tools available in the form of a Visual Studio add-in (project templates) and a runtime that allows Microsoft Office 2003 and later versions of Office applications to host the . NET Framework Common Language Runtime (CLR) to expose their functionality via .

How do you enable Excel add-ins for all users?

To activate an Excel add-inClick the File tab, click Options, and then click the Add-Ins category. In the Manage box, click Excel Add-ins, and then click Go. The Add-Ins dialog box appears. In the Add-Ins available box, select the check box next to the add-in that you want to activate, and then click OK.


2 Answers

Typically, when I am developing against multiple versions of Office with VSTO Add-ins, I have a project for each version of Office I am targeting. I put all common code between the projects into a single project (typically the oldest project) and use linked files, I add the common files to the newer projects. This allows me to write one set of common core code, abstracted from the requirements of each version of Office. This means I am no longer fighting the different ways VSTO is compiled for each version of Office. This can be made easier with shared folders and virtual machines, so I can develop and test without multiple computers. It is by no means graceful, but it works well for me. This should allow you to develop your VSTO Add-in against both Office 2007 and Office 2010 without much issue.

like image 154
Pete Garafano Avatar answered Nov 15 '22 23:11

Pete Garafano


To get VS 2010 working with Office 2007 modify the project file (.csproj) so that it will open in Office 2007 and not look for Office 2010 when run (hence the error message above).

Here is the project settings change (Excel example):

Source XPath:

//Project/ProjectExtensions/VisualStudio/FlavorProperties/ProjectProperties/@DebugInfoExeName

Old Value (Office 2010):

DebugInfoExeName="#Software\Microsoft\Office\14.0\Excel\InstallRoot\Path#excel.exe"

New Value (Office 2007):

DebugInfoExeName="#Software\Microsoft\Office\12.0\Excel\InstallRoot \Path#excel.exe"

After changing this project setting, when you fire up the debugger (F5) it will load the Excel 2007 application instead of looking for Excel 2010.

like image 44
SliverNinja - MSFT Avatar answered Nov 15 '22 23:11

SliverNinja - MSFT