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 Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
Microsoft 365 and Office | Development | Other
SQL Server | Other
{count} votes

2 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 41,491 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 60,161 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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.