Cannot debug or run Word AddIn because the required version of Microsoft Office is not installed

旧时模样 提交于 2019-11-28 19:42:54

问题


I need to work on an existing Word 2007 addIn project that's a part of a MSVS 2008 solution. However, when I try to debug the addIn, I get the following error message: "You cannot debug or run this project, because the required version of the Microsoft Office application is not installed". I have Office 2007 installed.

I tried creating a new Word 2007 addIn project in the same solution, and I have no problem debugging it. As far as I can tell, all the referenced Office assemblies are the same between these two projects.

Referenced Office assemblies:

Microsoft.Office.Interop.Word (c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.Word.dll)

Microsoft.Office.Tools.Common.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.Common.v9.0.dll)

Microsoft.Office.Tools.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.v9.0.dll)

Microsoft.Office.Tools.Word.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.Word.v9.0.dll)

Office (c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Office.dll)

stdole c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\stdole.dll

I tried rebuilding, starting debug under both Debug and Release configurations. Nothing helps. What else am I missing that could cause a problem with debugging the old project?


回答1:


Apparently, when the addin project is created, debug information such as the MS Office version and the executable path used for debugging is saved in the .CSPROJ file.

So debug is not guaranteed to work on another machine.

This information is saved in following XML node of the project file:

ProjectExtensions \ VisualStudio \ FlavorProperties \ ProjectProperties

In my case, the problem was in the attributes

  • OfficeVersion="14.0"
  • DebugInfoExeName="#Software\Microsoft\Office\14.0\Word\InstallRoot\Path#WINWORD.EXE"

Changing 14.0 to 12.0 (2010 to 2007) in their values solved my problem.

Check out these questions for reference:

  • Determine Excel 2007 addin vs excel 2010 addin
  • convert an Excel 2010 addin to a 2007 addin (both VSTO)



回答2:


For the benefit of searchers, I hit this error in Visual Studio despite referencing the correct version in the section mentioned by @sdds.

For me the fix was:

  1. Go to the project properties in visual studio
  2. Go to the 'Debug' tab
  3. Click the 'Start External Program' radiobutton
  4. Enter the path to the Office Application e.g. C:\Program Files\Microsoft Office 15\root\office15\winword.exe
  5. Run the project.



回答3:


I had the same issue, I changed the officeversion attribute & I had to install office 2010 with the currently installed office 2013



来源:https://stackoverflow.com/questions/18250511/cannot-debug-or-run-word-addin-because-the-required-version-of-microsoft-office

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!