C# Microsoft.Office.Interop.Excel missing

jassie

Well-known member
Joined
Nov 13, 2012
Messages
61
Programming Experience
1-3
In a C# 2008 application, I am getting the following error message:"
Could not resolve this reference. Could not locate the assembly "Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors."

I would like to ask the following questions:

1. The workstation I am installing the excel.interop has excel 2010 installed on it. However the reference points to excel 2007.
Thus can you tell me which interop I want to use excel 2007 or excel 2010?

2. When I downloaded the interop for 2010, i tried to add the assembly reference to the visual studio 2008 solution file. However from the references in solution explorer, I selected add references and then I selected the .net tab. I could not find the interop reference.

3. I originally downloaded the interop file from the link:
Download 2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies from Official Microsoft Download Center.
4. The readme directions said to do the following:
a. Double-click the O2007PIA.msi file and I did this.

b. Execute “msiexec.exe /i O2007pia.msi”. I then went to a command prompt, changed the directory path of where the the msi installer was located at above. I then hit the enter key.
c. I did not reboot (restart) the workstation.
d. I went to the control panel and found that the interop for 2007 was installed.
e. I then went to solution explorer, right clicked on references and selected the .net and com tabs. I would not find a reference for this 2007 interop.
f. I then went to solution explorer, right clicked on references and selected I sent to the following directory path C:\Program Files (x86)\Microsoft Office and found folfers for office11, office12, and office14.
I do not know what reference to attach to this application.

Thus can you tell me if I should proceed somehow with what I am trying right now and/or should I
try downloading the Office PIAs v14.0 to the workstation and see if it will run OK then
from the following location:

Download Microsoft Office 2010: Primary Interop Assemblies Redistributable from Official Microsoft Download Center?

Thus can you tell me what you think the best way to proceed is? If I download what you suggested, can you tell me where and how I will find the interop 2007 that I need to attach to this application?
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,272
Location
Sydney, Australia
Programming Experience
10+
If you want to support one specific version of Office then you must reference that version. If you want to support multiple versions then you can't reference any version and you must use late-binding in your code.

Office is COM so you generally use the COM tab to add a reference. I've always used an Office installation rather than a PIA but I think that it should still be the same. If not then you might have to browse to the Interop DLL itself.
 
Top Bottom