PIA updates

Add-in Express™ Support Service
That's what is more important than anything else

PIA updates
 
Xavier N


Guest


Hello,
A small question concerning PIA this time...
Since Office 2016, we can use 3D Models.. And Excel/PowerPoint VBA Object Model (at least in Offie 2019) add "Add3DModel" method to "Shapes" Object to do so in Excel, Powerpoint, Word. The method is present for more than one year in VBA but it's not present in the latest Excel, Powerpoint PIA...

Any idea why Microsoft has not updated the PIA when he updated the VBA Model ?
And of the frequency of updates concerning PIA (the latest Excel PIA in Nuget is 10/03/2016...) ?

Regards
Xavier
Posted 12 Mar, 2020 03:00:23 Top
Andrei Smolin


Add-in Express team


Posts: 18847
Joined: 2006-05-11
Hello Xavier,

We don't know when Microsoft updates PIAs and why. You can use late binding to perform these calls.


Andrei Smolin
Add-in Express Team Leader
Posted 12 Mar, 2020 03:54:40 Top
Xavier N


Guest


Late binding (InvokeMember) is OK to call the method for Shapes Object..
Thanks for the solution Andrei..
Regards, Xavier
Posted 12 Mar, 2020 04:52:19 Top
Andrei Smolin


Add-in Express team


Posts: 18847
Joined: 2006-05-11
Welcome!


Andrei Smolin
Add-in Express Team Leader
Posted 12 Mar, 2020 05:10:04 Top
Xavier N


Guest


Hello,

PIAs are a historical artifact, required only by old .NET versions (before v4). They have been thoroughly and elegantly replaced by the "Embed Interop Types" feature, also known as the "No PIA" feature...
https://stackoverflow.com/questions/21013912/can-i-still-use-microsoft-office-interop-assemblies-with-office-2013


Following investigation and the previous stackoverflow question/answer i tried to embed Excel/Office Interop Types using the recommanded method. Using Com Tab (Project > Reference > Insert > Com (Tab) > Microsoft Excel 16.0 Object Library).

It'ok and adding Excel 16.0 Object Library also add by default the Office 16.0 Object Library. (*: it creates and reference a Microsoft.Office.Interop.Excel.dll file : C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel \15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll and also a Microsoft.Office.dll (Core))

I thought i would get access to the whole updated Excel/Office Com Object model (as in my Excel VBA Developer Window). But i can't ! I mean, Excel Shapes in intellisense has no "Add3Model" method (as in VBA), .Net Enum MsoShapeType is limited to 28 member (but VBA Enum MsoShapeType has now 33 member: msoGraphic, msoLinkedGraphic... and now mos3Dmodel)

Updated post (29/03):
(*) Well, indeed, the Excel interrop assembly file was not generated. I suppose, as a previous Excel 2016 assembly was already referenced, it simply create a reference to the old one in C:\WINDOWS\assembly\GAC_MSIL..
I wonder if i remove the GAC Excel interrop assembly and regenerate the process, if it will create a new updated Interop assembly with the new methods... But i fear to do so.

It seems you can also create an interop assemblies using tlbimp-exe:
https://docs.microsoft.com/en-us/dotnet/framework/interop/how-to-generate-primary-interop-assemblies-using-tlbimp-exe
https://stackoverflow.com/questions/11872543/preventing-tlbimp-from-generating-interop-assemblies-for-referenced-type-librari

It may be a safer solution (creating without registering), but i fear it only works on my machine...
Not sure to understand the ins and outs. I suppose that, if it was working, a good will/microsoft will have updated the interrop assemblies on nuget or addin express would integrate updated interrop assemblies..

Stopping here ivestigations..

Regards. Xavier
Posted 28 Mar, 2020 03:53:49 Top
Andrei Smolin


Add-in Express team


Posts: 18847
Joined: 2006-05-11
Hello Xavier,

Xavier N writes:
I thought i would get access to the whole updated Excel/Office Com Object model (as in my Excel VBA Developer Window).


As far as I know, there's no Excel interop containing methods, properties and enum values relating to 3D images.

Xavier N writes:
it simply create a reference to the old one


Exactly.

Xavier N writes:
if it will create a new updated Interop assembly


I suppose it won't work: it should look for a primary interop assembly (see https://docs.microsoft.com/en-us/visualstudio/vsto/office-primary-interop-assemblies?view=vs-2019) and I suppose it would find the interop assembly that you already use.

I've tried to use TLBImp.exe to create such an interop; I received an error "Primary interop assembly 'Microsoft.Office.Interop.Excel,[...]' is already registered for type library [path]\EXCEL.EXE". I probably miss something.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Mar, 2020 03:17:43 Top
Xavier N


Guest


Thanks a lot Andrei for your investigation and tests..

As far as I know, there's no Excel interop containing methods, properties and enum values relating to 3D images.

That's true. It a bit sad. The object model include it and VBA can access it for two year now. But as Interop are not updated we can't. I suppose that's part of Ms strategy.. When you get access to Office developer support site https://developer.microsoft.com/fr-fr/office/docs, we are now oriented to Javascript APi. We can also find VBA but no information on Com addins anymore... So i suppose we can wait a long time before they update inyterrops...


I received an error "Primary interop assembly 'Microsoft.Office.Interop.Excel,[...]' is already registered..

Some developer report it was just a "warning" but without real effect on the interrop generated ..(https://www.mztools.com/articles/2012/MZ2012011.aspx, https://stackoverflow.com/questions/16689753/excel-add-in-warnings)
But it may be an "error" now...
Anyway it's not simple and TLBImp has many flags to understand...
And Excel.exe also depends on the mso.dll. So it seems you have to generate Mso.dll interops before (cf. https://stackoverflow.com/questions/11872543/preventing-tlbimp-from-generating-interop-assemblies-for-referenced-type-librari)...

Thanks again for your search Andrei

Regards
Xavier
Posted 30 Mar, 2020 04:04:19 Top
Andrei Smolin


Add-in Express team


Posts: 18847
Joined: 2006-05-11
Xavier N writes:
Some developer report it was just a "warning"


My fault, that was a warning. The error was: TlbImp : error TI1033 : Cannot find type 'Microsoft.Office.Core.DataPrivacyOptions' in 'Office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. There could be a mismatch between the referenced assembly and the type library.

Xavier N writes:
That's true. It a bit sad. The object model include it and VBA can access it for two year now. But as Interop are not updated we can't.


You can use late binding.

I've run in an issue when I tried to use TLBImp to create an interop for Office.Core. Start Excel, open a workbook, press {Alt+F11} to open the VBA IDE, press {F2} to open the VBA Object Browser, in the topmost checkbox switch to "Office". For me, the Comments area provides this info:

Library Office
C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16\MSO.DLL
Microsoft Office 16.0 Object Library


The issue is: that file is missing in that folder. That file is only present if I open that folder using a File| Open dialog from the Excel application itself; this is a result of using a Click-to-Run Office version.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Mar, 2020 05:48:06 Top
Xavier N


Guest


You can use late binding

You're right Andrei... And i'm using it.. But it' a little bit annoying to invoke it that way. From 3 years, i 'v seen VBA Object model intagrating new feature little by little. Fo example VBA enum MosShapeType include now 33 constants thats were added once at time to manage Icon SVG, 3D model... (.Net is blocked to 28 for 4 years now even if you can use casting Ctype(31, Office.MsoShapeType)...

MSO.DLL > The issue is: that file is missing in that folder.

That's a strange thing..
VBA reference MSO.DLL in "C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16\MSO.DLL" but indeed the file do not exists there but in "C:\Program Files (x86)\Microsoft Office\root\VFS\ProgramFilesCommonX86\Microsoft Shared\OFFICE16\MSO.DLL". It's a kind of hidden redirection...
(this is the path i found when i've tried to import the reference using Com Tab..

Regards
Xavier
Posted 30 Mar, 2020 06:27:22 Top
Andrei Smolin


Add-in Express team


Posts: 18847
Joined: 2006-05-11
Hello Xavier,

Xavier N writes:
But it' a little bit annoying to invoke it that way.


I agree.

Xavier N writes:
It's a kind of hidden redirection...


I suppose that's a variation of the machinery they implemented in Office from Store; see https://www.add-in-express.com/creating-addins-blog/2019/02/27/office-from-store-issues/.


Andrei Smolin
Add-in Express Team Leader
Posted 31 Mar, 2020 00:53:52 Top