Some library to run a powershell script that uses Excel COM classes without Office installed?

0

Is there some microsoft libary that installs the COM classes needed without actually installing O365 on a server to just run a powershell program? When we try to run on a workstation with O365, no problem but if we run on a server without O365 installed we get this sort of error:

New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
+ $excel = New-Object -ComObject excel.application
    + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
excel
powershell
asked on Stack Overflow Apr 7, 2021 by BruceP

1 Answer

5

As far as I know the Excel Object Model (EOM) is only installed with Excel. I don't know of a way to get the model installed otherwise. However, ImportExcel a PowerShell module from MVP Doug Fink can work with Excel workbooks without Excel installed. I use it all the time, and would argue it's easier too.

See this Scripting Guys article with techniques using ADO (COM) & ADO.Net to access Excel data.

I also double checked if Visual Studio Tools for Office (VSTO) and/or MS Office Primary Interop Assemblies could be used for this. However, these assemblies appear to act as an interface between managed code and the COM objects (EOM).

answered on Stack Overflow Apr 7, 2021 by Steven • edited Apr 7, 2021 by Steven

User contributions licensed under CC BY-SA 3.0