Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154

sandeep singamaneni 0 Reputation points
2024-04-14T20:25:01.46+00:00

I have a simple PowerShell script as below 

$excel = new-object -ComObject excel.application 

$filePath = 'filename.xlsm' 

$wb = $excel.workbooks.open($filePath) 

$excel.Run('Macro') 

$excel.quit() 

Stop-Process -Name "Excel"

When I trigger the script either in SSIS package or through Task Scheduler, it works as expected. But when I deploy the SSIS package in SSMS and trigger the script as SQL Server agent job, I get the error as "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))..".

I made sure I have Excel installed and also entries exist for both InProcServer and LocalServer with CLSID {00024500-0000-0000-C000-000000000046} in Registry Editor. I also registered the dll in InProcHandler32 which is ole32.dll using regsvr32.exe. I also tried replacing the powerShell script with python using win32com library. But getting the error "pywintypes.com_error: (-2147221005, 'Invalid Class string', None, None). We want to migrate the jobs in Task Scheduler to SQL Server agent.

I am not sure why my log shows CLSID as {00000000-0000-0000-0000-000000000000}, when I am trying to open excel with CLSID {00024500-0000-0000-C000-000000000046}. I am not sure even if they are related. Can anyone help me troubleshoot the error.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,757 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,456 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,508 questions
{count} votes

2 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 33,126 Reputation points
    2024-04-15T06:21:26.7166667+00:00

    Hi @sandeep singamaneni,

    As you succeed in running the package in Visual Studio and it fails run by SQL Job - the most probable case is that SQL Server Agent service account does not have permission to the Excel file.

    You may create a proxy account which has access to the Excel file.

    Running a SSIS Package from SQL Server Agent Using a Proxy Account

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.


  2. Michael Taylor 48,576 Reputation points
    2024-04-15T19:12:25.5033333+00:00

    Are you running your SSIS package in the x64 DTS host? Try running your SSIS package on the server using the x86 host instead.