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.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/5cd97e4e-8163-4ecb-9103-970e22c8bf31n%40googlegroups.com.