44

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?

Community
  • 1
  • 1
sdds
  • 2,021
  • 2
  • 25
  • 33

3 Answers3

75

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:

Community
  • 1
  • 1
sdds
  • 2,021
  • 2
  • 25
  • 33
  • 2
    Exactly my issue when moving to a new development machine. Opened the .csproj file with notepad and changed 15 to 14 (Office 365 to Office 2010). – Watson Jan 27 '14 at 21:05
  • Can't believe it, it worked. I had the case Outlook 2010 on one machine, 2013 in the other (changed version 14.0 to 15.0). Thank you. – anhoppe Feb 14 '14 at 21:29
  • Works for PowerPoint 2013 -> 2010. – illagrenan Mar 12 '14 at 20:13
  • Thanks for this. Works when rolling back to Excel 2010 from Excel 2013. – Steven C. Britton Jul 11 '14 at 05:38
  • Worked for me as well, replaced `14.0` with `15.0` and works like a charm. – mzi Sep 01 '14 at 14:52
  • In VS2013, changing OfficeVersion to 12 for Office 2007 did not work (VS repeatedly asked to upgrade the project file). Changing only the DebugInfoExeName attribute made the trick. – personne3000 Apr 23 '15 at 01:48
  • It works for me too :) in my case I changed DebugInfoExeName="#Software\Microsoft\Office\15.0\Word\InstallRoot\Path#WINWORD.EXE" to DebugInfoExeName="#Software\Microsoft\Office\12.0\Word\InstallRoot\Path#WINWORD.EXE" for MS Word 2007 I installed – X-Coder Feb 20 '16 at 06:00
  • Office 2013 to 2016 change version from 15 to 16 – Marcos Brigante Aug 05 '16 at 13:02
39

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.
JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123
  • I ran into this when a project seemingly wouldn't build after refreshing the project tree. Turns out it's been broken a long time but I have had the explicit EXE in the Debug tab for ages because I pass commandline parameters to Word. Those are stored in *.csproj.user, and I hadn't saved the .user file in the repository. – Wade Hatler Aug 20 '15 at 03:13
  • this was a fix for me I needed when going between Excel 2016/2013 – punkouter Dec 16 '15 at 17:52
  • Fix for me going 2013 to 2016, same as @punkouter – interesting-name-here Apr 07 '16 at 15:12
  • 1
    or C:\Program Files (x86)\Microsoft Office 2013\Office15\winword.exe – kmote Apr 28 '16 at 16:52
  • Worked for me. Plugin was developed/tested with Office Outlook 2016 and I'm running Office Outlook 2013. Just changed external program to point to my C:\Program Files\Microsoft Office\Office15\OUTLOOK.exe. – broadband Jan 30 '17 at 15:01
  • This is the correct answer in my opinion. You shouldn't have to go the .csproj (or .vbproj file for VB) and should be able to use the GUI – ptownbro Jun 22 '17 at 15:26
-1

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

Doicare
  • 361
  • 1
  • 3
  • 15