Error microsoft office interop excel

I am having troubles adding the excel reference to my project. I have already installed Primary Interop Assemblies.

The project is detecting the Microsoft.Office.Interop.Word assembly reference correctly but the excel reference still cannot be found.

When I try to manually add the reference, I right click the project, add reference, navigate to the Microsoft.Office.Interop.Excel file and try to add it manually. Once i select the reference I then make sure the reference is checked, then hit ok. Nothing happens, it fails to actually add the reference path to the project.

Using VS2012 Ultimate.

Any suggestions on what I can do to get the project to see the excel reference?

41686d6564 stands w. Palestine's user avatar

asked Oct 23, 2013 at 13:38

stylex's user avatar

6

If you don’t have excel installed, run this command in the nuget-packet-manager-console:

Install-Package Microsoft.Office.Interop.Excel

answered Apr 14, 2017 at 14:51

Luca Ziegler's user avatar

Luca ZieglerLuca Ziegler

3,0981 gold badge22 silver badges39 bronze badges

I installed Microsoft office PIAs, but I had the same problem, cannot find microsoft.office.interop.excel dll, I also I installed Visual Studio 2010 Tools for the Office System 4.0 Runtime Service Pack 1 but still the problem persist.

Finally I resolve the problem with an add of Office / SharePoint development package to my Visual Studio 2017 installation:

Go to Tools > Get Tools and Features ..

And then check Office / sharepoint development and modify your installation.

answered Apr 4, 2018 at 15:03

Mohammed EL KALAKHI's user avatar

1

I installed MS Office 13 and from then on I started getting this error in VS 2012 project.
I tried adding the MS Office lib via COM control but that didnt work.
Finally I had to add this library references from the «Extensions» section (not not under COM); had to select Microsoft.Office.Interop.Excel, version 15.0.0.0. That fixed the error.

Hope that helps some.

answered Apr 11, 2016 at 19:16

Yoda's user avatar

  • Remove From My Forums
  • Question

  • My asp.net application is throwing this exception:

    Could not load file or assembly ‘Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified.

    I’ve installed:

    Microsoft Office Access Database Engine 2007

    Microsoft Office 2003 Web Components

    In the code, I’m importing Microsoft.Office.Interop and using classes in the Excel namespace. It works on one of my other test servers but not this one. I don’t have office installed on either servers, but it works on one but not the other.

    I’ve checked C:windowsassembly for any differences, but I don’t see anything.
    I’ve searched for excel.dll, office, interop on the hard drives but nothing obvious comes up.

Answers

  • hey Btabios,

    the interop libraries are not part of .NET framework itself, rather part of visual studio.  you can the copy the Interop library from «Program FilesMicrosoft Visual Studio 9.0Visual Studio Tools for OfficePIAOffice12» and paste on the server.  please refer to the following topic to understand how assemblies are loaded.  http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx

    i have added the interop assembly in GAC using gacutil provided with .NET Framework 2.0 and it exists peacefully with interop library 11.

    regards,


    kashif

    • Marked as answer by

      Thursday, February 18, 2010 4:41 PM

  • Hi Kashif,

    Here is what I’ve tried.

    1. Create a project that installs Microsoft.Office.Interop.Excel.dll 12.0.0.0 into the GAC. It also automatically installed office.dll and Microsoft.Vbe.Interop.dll into the GAC
    2. Verified that the files existed in C:WindowsAssembly folder.
    3. Restarted the server.

    I’m still getting the error as noted above. I’m thinking of just buying office as Yasser suggested. Does anyone know what version I need to buy? Will Office 2007 include the proper libraries?

    • Marked as answer by
      BTabios
      Friday, February 26, 2010 5:04 PM

  • I’m going to mark Kashif’s reply as the answer to my problem.

    After installing Microsoft.Office.Interop.Excel.dll version 12.0.0.0 into the GAC and restarting the server. ASP.NET seems to find the proper assembly correctly. I am no longer received the above exception.

    The new exception I am getting is:
    Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.

    After initial research and some unsuccessful troubleshooting I’ve decied to go ahead and purchase Excel for our server. This should install the excel libraries correctly and I should be able to program against the Excel classes without error.

    • Marked as answer by
      BTabios
      Friday, February 26, 2010 5:04 PM

Студворк — интернет-сервис помощи студентам

Добрый день!

Собственно есть Win10, Visual Studio 2019, есть MS Office 2007 с установленным Excel.
При попытке подключиться к Excel вылезает ошибка «Could not load file or assembly «Interop.Microsoft.Office.Interop.Excel, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null»» и прочее.
Ссылка на библиотеку добавлена (Microsoft Excel 12.0 Object Library версия 1.6). Цепляется из папки с офисом из файла Excel.exe.
В «C:Windowsassembly» Microsoft.Office.Interop.Excel присутствует.
Весь код

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
using System;
using Excel = Microsoft.Office.Interop.Excel;
 
namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            Excel.Application wordApp = new Excel.Application();
        }
    }
}

DLL-ка Interop.Microsoft.Office.Interop.Excel.dll в папке Debug появляется после запуска. Наличие какого-либо осмысленного кода для работы с экселем ничего не дает, т.к. до него дело не доходит.

Единственное, что я заметил, это отличие версии в «C:Windowsassembly» (12.0.6600.1000) от той, которая отображается в проекте (12.0.6771.5000).

PS. Да, я находил темы про эту же ошибку, но не нашел в них решения.

  • Remove From My Forums
  • Question

  • I am using VS 2012 to create SSIS.
    I have a Script that has a reference to Excel 2013 — Microsoft.Office.Interop.Excel (Add Reference — Assemblies — Extensions, then select Microsoft.Office.Interop.Excel 15.0). In the Reference Properties, the path is C:Program Files (x86)Microsoft
    Visual Studio 12.0Visual Studio Tools for OfficePIAOffice15Microsoft.Office.Interop.Excel.dll.

    I run the SSIS package by going to SQL Server Management Studio — Integration Services Catalogs — SSISDB, right click on the package and Execute.
    The SSIS package runs fine on my machine, but when running it on the server (we already installed Excel 2013 on the server), I get this error:
    Retrieving the COM class factory for component with CLSID {…} failed due to the following error: 80070005 Access is denied.

    I can’t find Microsoft.Office.Interop.Excel.dll on the server (even though Excel 2013 was already installed on the server).

    How can I fix this error ?

    Thank you.

     

    • Edited by

      Tuesday, July 19, 2016 8:09 PM

Это код, который я использовал до установки Office 2016.

var excelApp = new Excel.Application();
excelApp.Visible = true;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(finfo.FullName, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "t", false, false, 0, true, false, false);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
var cellValue =(excelWorksheet.Cells[a, b] as Excel.Range).Value;

Код работал нормально, но после установки Office 2016 я увидел, что не могу использовать using Excel = Microsoft.Office.Interop.Excel;

Единственная совместимая библиотека, которую я нашел,

Microsoft.Office.Core (библиотека объектов Microsoft Office 16.0)

Я не смог найти примеров доступа к файлам Excel. Есть ли другой способ доступа к файлам Excel с установленным Office 2016 (PIA)

Это ошибка, которую я получаю, когда пытаюсь запустить код

Невозможно привести объект COM типа «System.__ComObject» к типу интерфейса «Microsoft.Office.Interop.Excel.Application». Эта операция завершилась неудачно, поскольку вызов QueryInterface в компоненте COM для интерфейса с IID ‘{000208D5-0000-0000-C000-000000000046}’ не выполнен из-за следующей ошибки: Интерфейс не зарегистрирован (Исключение из HRESULT: 0x80040155).

Понравилась статья? Поделить с друзьями:
  • Error in load dll excel
  • Error excel this workbook
  • Error driver odbc excel
  • Error checking for excel
  • Error 450 vba excel