Gopal SA
Gopal SA

Reputation: 959

Excel VSTO project not loading after upgrading from Office 2013 to Office 2016

I get the below error on loading the project with VS 2013 (with Office 2016 installed)

Cannot create the project because the application associated with this project type is not installed on this computer. You must install the Microsoft Office application that is associated with this project type.

The C# project was originally created as Excel Workbook using VS 2013 with Office 2013 and runtime as 'Visual Studio 2010 Tools for Office Runtime'. .Net Framework has also not changed. Everything looks good to me as per https://msdn.microsoft.com/en-us/library/bb772080.aspx

When I looked inside the .csproj file, I found the below references to Office Dll's, Office versions and the ProjectProperties section was pointing to C:\Program Files\Microsoft Office\Office15\Excel.exe which does not exist after the upgrading to Office 2016.

What are all the things that i need to manually repair within the .csproj file to get the project loading?

 <ItemGroup>
    <Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <Private>False</Private>
    </Reference>
    <Reference Include="Office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
      <EmbedInteropTypes>true</EmbedInteropTypes>
    </Reference>
    <Reference Include="Microsoft.Vbe.Interop, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
      <EmbedInteropTypes>true</EmbedInteropTypes>
    </Reference>
    <Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
      <EmbedInteropTypes>true</EmbedInteropTypes>
    </Reference>
  </ItemGroup>

.....

<ProjectProperties HostName="Workbook.xlsx" HostPackage="{3F2B7691-D1D1-402F-9370-2704A737CF60}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="XLS" Language="CS" TemplatesPath="VSTOTemplates" DebugInfoExeName="C:\Program Files\Microsoft Office\Office15\Excel.exe" DebugInfoCommandLine="/x &quot;[$OUTPUT]Workbook.xlsx&quot;" />

Upvotes: 0

Views: 1077

Answers (1)

MauriDev
MauriDev

Reputation: 445

I solved a similar problem in Visual Studio 2015, maybe this will help.

I manually edited the file .csproj outside Visual Studio, changed the attribute OfficeVersion="15.0" in the ProjectProperties element with OfficeVersion="14.0" (yes! Downgrade it!)

Then when I opened the solution in Visual Studio, the project was tagged with (needs migrations), then when I tried to reload the project Visual Studio asked to migrate the project and then did all the work.

N.B. First ensure that you are able to create a new project "Excel 2013 and 2016 VSTO Workbook", if not try to update Excel and verify that the VSTO Add-In is enabled

Upvotes: 1

Related Questions