Error when running a powershell script

Pamu 86 Reputation points
2020-11-19T03:01:52.263+00:00

Hi everyone, When I try to run this poweshell script .. it gives the error saying

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

At C:\Users\user1\Desktop\ClientSubmissionDetail.ps1:27 char:20
+ $excelObject = New-Object -ComObject Excel.Application

+ CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
 + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

The property 'Visible' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\user1\Desktop\ClientSubmissionDetail.ps1:28 char:5
+     $excelObject.Visible = $false
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The error go on like this Can anyone please help ?

Excel Management
Excel Management
Excel: A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.Management: The act or process of organizing, handling, directing or controlling something.
1,653 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,399 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 31,016 Reputation points Microsoft Vendor
    2020-11-19T08:14:18.733+00:00

    Hi,

    Is Microsoft Office installed? If yes you can try to repair it.

    Repair an Office application
    https://support.microsoft.com/en-us/office/repair-an-office-application-7821d4b6-7c1d-4205-aa0e-a6b40c5bb88b

    Best Regards,
    Ian

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Rich Matheisen 45,111 Reputation points
    2020-11-21T15:39:29.867+00:00

    Are you running the script from PowerShell, the ISE, or some other place?

    Try placing this at the beginning of your script and see if you're running the 64 or 32 bit version of Powershell:

    [Environment]::Is64BitProcess
    

    It may be that you're trying to use a 64-bit DLL from a 32-bit process and the registration of the DLL isn't in the right part of the registry.


  3. IT Magician 1 Reputation point
    2021-12-31T15:51:49.513+00:00

    I am also having this issue on fully patched Windows 10 machines. I have a new thread here: https://learn.microsoft.com/en-us/answers/questions/677642/powershell-fails-to-launch-excel-with-clsid-com-er.html

    0 comments No comments