I have MS office installed, and I also have MS Visual Studio installed, but when I trying to add the reference Microsoft.Office.Interop.Excel.dll.
It is nowhere to be found. I have tried reinstall Visual Studio and still cannot find it. Any help?
Do the following steps, which should be helpful in finding, adding, and using the Microsoft.Office.Interop.Excel.dll
reference.
- Start Visual Studio.
- On the File menu, point to New, and then click Project. The New Project dialog box appears.
- In the
Installed Templates
pane, expandVisual C#
, and then click Windows. - Look at the top of the New Project dialog box to make sure that
.NET Framework 4
(or later version) is selected as a target framework. - In the Templates pane, click Console Application.
- Type a name for your project in the Name field.
- Click OK.
The new project appears in Solution Explorer.
To add Microsoft.Office.Interop.Excel.dll references
- In Solution Explorer, right-click your project’s name and then click Add Reference. The Add Reference dialog box appears.
- On the Assemblies page, select
Microsoft.Office.Interop.Word
(optional) in the Component Name list, and then hold down the CTRL key and selectMicrosoft.Office.Interop.Excel
. If you do not see the assemblies, you may need to ensure they are installed and displayed. - Click OK.
To Add the Reference, use the following directives:
- In Solution Explorer, right-click the
Program.cs
file and then click View Code. - Add the following
using
directives to the top of the code file:
using Excel = Microsoft.Office.Interop.Excel; using Word = Microsoft.Office.Interop.Word;
If not, install the necessary version of Microsoft Office that matches your Visual Studio configuration. If Microsoft Office is already installed, try adding the reference to the DLL manually. You can do this by right-clicking on your project, selecting “References,” then “Add Reference,” and browse for the DLL file. Once added, rebuild your project, and the error should be resolved.