Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# not recognizing the interop.office.Excel.dll

After adding the reference to the interop.office.Excel.dll in VS2015, F# (4.0, .net 4.6.1) still not able to recognizing the type under the Excel.dll.

enter image description here

The reference to the Excel.dll looks like

enter image description here

As a comparison, i created a C# project with same reference there is no issue finding the reference.

Strangely, the F# code does compile, if reference the workbook object under the excel dll. (i just have to treat it as if it was a dynamic type) only the intellisense is not working.

any suggestion? thanks

like image 818
casbby Avatar asked Oct 18 '22 03:10

casbby


1 Answers

Most probably (just as the error message says), you need to add a reference to the office.dll (in FSI or in the VS's References). There can be various versions of excel and office installed, so I just assume you're using Excel 2010 (which is Ver 14). In that case to make it explicit:

#r @"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Excel.dll"
#r @"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Visual Studio Tools for Office\PIA\Office14\Office.dll"
open Microsoft.Office.Interop.Excel

let xlApp = new ApplicationClass(Visible = true) 
xlApp.

xlApp will now have intellisense:

enter image description here

like image 62
s952163 Avatar answered Nov 15 '22 10:11

s952163