0
votes

I try to create a excel file in a powershell script using this code :

$xl = New-Object -ComObject "Excel.Application"
$xl.Visible = $false
$xl.DisplayAlerts = $false
$wb = $xl.Workbooks.Open($scriptPath + "\..\..\NeededTools\ExploitationApplication.xlsm")
$global:ws = $wb.sheets.Item(3)

And I face this exception :

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)).

Do someone have informations about this exception or a sample used to generate a excel file correctly ? Is it possible to have this error because I dont have excel on this server ?

3
Is excel installed on the machine?user844705
No, but I used other script who create csv files without troublesXavier W.
You cannot create the Com object if it is not there. That is what the error message is telling you. You need to install Excel for this to workuser844705

3 Answers

0
votes

You do not have Excel installed. Or you have, and need to run repair.

0
votes

I had the same problem in my Desktop from a C# application after a Windows/Office update from my company IT (Office16). It worked for 5 years without any problems.

I create a Powershell script that launch excel to update a table that works well in my Laptop but still not in my Desktop.

After long search and follow the indication from this link (https://social.technet.microsoft.com/Forums/lync/en-US/05a1635d-142c-4866-8455-1341280967fd/windows-explorer-preview-of-office-2016-files-does-not-work?forum=Office2016setupdeploy).

I found that some information was missing in the Windows registry.

In details: comparing the Registry key "Computer\HKEY_CLASSES_ROOT\WOW6432Node\CLSID{00024500-0000-0000-C000-000000000046}" from my Laptop, in my Desktop I had only one key, "InprocServer32" instead of 5 keys.

I added the following key folders and values under "Computer\HKEY_CLASSES_ROOT\WOW6432Node\CLSID{00024500-0000-0000-C000-000000000046}":

"LocalServer32" => default: "C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE /automation"
"ProgID" => default: "Excel.Application.16"
"VersionIndependentProgID" => default: "Excel.Application"
"InprocHandler32" => default: "ole32.dll"

Note: the "LocalServer32" was enough to run the script

Registry key structure

-1
votes

You do not have Excel installed. Or you have, and have to repair it.