Greycastle Logo

VSTO-project Office target version

When developing a VSTO-project you will probably sooner or later run into a case where you need to debug the project in two different versions of Office. One solution is to trigger the start of Word using a debug-setting in the project file:

Update 18/8 2014:
To reach these project settings, right-click the project file in solution explorer and select Properties, on this page you should find a debug “tab” in the left column.

This, however, doesn’t support breaking points etc. To really start up Word in a debuggable fashion you need to reconfigure/hack the project file and change the targeted Word version.

Ie changing from Office 2010 to Office 2007 means you need to change the following line in the VSTO-project file:

<ProjectProperties HostName="Word" HostPackage="{etc}" OfficeVersion="14.0" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#SoftwareMicrosoftOffice14.0WordInstallRootPath#WINWORD.EXE" DebugInfoCommandLine="/w" AddItemTemplatesGuid="etc" />

To this following:

<ProjectProperties HostName="Word" HostPackage="{etc}" OfficeVersion="12.0" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#SoftwareMicrosoftOffice12.0WordInstallRootPath#WINWORD.EXE" DebugInfoCommandLine="/w" AddItemTemplatesGuid="etc" />

Note that you don’t really want to change the VstxVersion since this is the interop assemblies for .Net 4 (VS 2010) which has so much better IntelliSense then the previous libraries.

Thank you Eric Segelberg for finding this neat trick!

© 2024 Greycastle