Latest Microsoft.Office.Interop dll's ?

432 views
Skip to first unread message

Guido De Bouver

unread,
Nov 22, 2023, 6:35:02 AM11/22/23
to Excel-DNA
dear ExcelDNA users,

I am a bit puzzled which Interop dll I should be using and where to get it from.

Via ExcelDNA.Interop via Nuget, I get a v2.0.50727.
I got a different version v4.0.30319 ( dont know wehre I downloaded it from )
And via NuGet Micorsoft.Office.Interop.Excel, I could get latest stable 15.0.4795

I am really confused = Which version should I be using - does it matter ?
I am targeting Office 365 ( 64 bit ) with the altest ExcelDNA version.

thank for your advise/help
fuido


Govert van Drimmelen

unread,
Nov 22, 2023, 7:20:47 AM11/22/23
to exce...@googlegroups.com

Hi Guido,

 

I recommend that you use the ExcelDna.Interop NuGet package – version 15.0.1.

 

<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />

 

This NuGet package includes a .targets build file that works with the other Excel-DNA build files, and also with .NET 6.

 

I don’t know what you mean when you say “I get a v2.0.50727.”

That might indicate that something is wrong…

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/bae0190d-a939-4786-a73f-5514b28a5280n%40googlegroups.com.

Guido De Bouver

unread,
Nov 22, 2023, 11:59:55 AM11/22/23
to Excel-DNA
Govert,

As soon as I swicth to the ExcelDna.InterOp package from NuGet, I get a Late Binding error, which I didnt get when I was using an older reference
I am compiling with Option Strict ON and the statements
Dim a1 = CType(ExcelDnaUtil.Appliication, Application)
Dim c1 = a1.ActiveCell
c1.Formula2 = "=SOMEFORMULA()"
gives me a "Option Strict On disallows late binding" error on the last statement, whilst it didnt on earlier Interop versions.

Strange - any idea ?


Govert van Drimmelen

unread,
Nov 22, 2023, 12:20:11 PM11/22/23
to exce...@googlegroups.com

Hi Guido,

 

Why doesn’t your Range type seem to have a Formula2 method?

The ExcelDna.Interop package version 15.0.1 contains the Excel version 15 (Excel 2003) Primary Interop Assemblies (PIAs).

As far as I know, this was the last version of the PIAs shipped by Microsoft.

 

When Excel version 16 was released (Excel 2016) there were some additions to the COM object model, like Range.Formula2, but no official set of PIAs.

So that’s why you get the Option Strict error – this version of the interop assembly does not have the Range.Formula2 method yet.

 

You can, however, generate an interop assembly from the COM type library on your machine when building. If your machine has Excel 2016 or later, it will create that interop assembly with the extra method(s).

 

Are there any important differences between a “Primary Interop Assembly” and an interop assembly generated at build time from the COM type library?

I don’t know. I think the difference might have been important before .NET 4.0, but no longer.

 

How can you change your project from the Excel 15 PIAs in the ExcelDna.Interop v 15.0.1 package to a COMReference that makes the interop assembly when building?

You take out the PackageReference and add this to the project file:

 

  <ItemGroup>

    <COMReference Include="Microsoft.Office.Interop.Excel">

      <WrapperTool>tlbimp</WrapperTool>

      <VersionMinor>9</VersionMinor>

      <VersionMajor>1</VersionMajor>

      <Guid>00020813-0000-0000-c000-000000000046</Guid>

      <Lcid>0</Lcid>

      <Isolated>false</Isolated>

      <EmbedInteropTypes>true</EmbedInteropTypes>

    </COMReference>

  </ItemGroup>

 

Then your Option Strict On code will work with Range.Formula2.

However, note that your project build will now depend on the Office installation on the build machine.

(One might make a plan by managing the interop assemblies yourself, but that’s a step further along the way.)

 

I hope this gives you a better idea of what is going on.

 

-Govert

 

 

From: exce...@googlegroups.com <exce...@googlegroups.com> On Behalf Of Guido De Bouver


Sent: Wednesday, November 22, 2023 7:00 PM
To: Excel-DNA <exce...@googlegroups.com>

--

You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.

Guido De Bouver

unread,
Nov 22, 2023, 1:00:35 PM11/22/23
to Excel-DNA
Too complicated for me :-) but thanks for the information.
I will live with the Option Strict OFF setting :-)
thanks
guido
Reply all
Reply to author
Forward
0 new messages