Running macro from ssis

0

I developed an SSIS package that ran Excel macros (VS2008, SQL Server 2008 and Windows Server 2008 if I remember correctly - servers were decommissioned). The package was migrated to Azure using SQL Server 2016 and VS2015.

We are now running it for the first time in over a year and it's failing. Original code for running the macro from SSIS was taken from here Run an Excel Macro from SSIS.

Code:

using System;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop;
using Excel = Microsoft.Office.Interop.Excel;

public void Main()
{
    Excel.Application xlApp = new Excel.Application();
    Excel.Workbook xlWorkBook = xlApp.Workbooks.Open("C:\\ExcelDirectory\\DATA.xlsm"); // absolute path needed
    xlApp.Run("Formatting"); // method overloads allow you to send it parameters, etc.
    xlWorkBook.Close(true); // first parameter is SaveChanges
    xlApp.Quit();
}

Error on line 1 of Public void Main:

Additional information: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Interop reference was added although manually because the install (exe) from MS would not do the job. Maybe the .dll's are no good? Please help and keep in mind I am a novice in this area.

c#
excel
ssis
sql-server-2016
asked on Stack Overflow Oct 10, 2017 by havek • edited Oct 10, 2017 by marc_s

1 Answer

0

Problem solved!! The issue is, as others have stated in other posts, I need Office installed. Interop on its own will NOT run macros or interact with Office products.

answered on Stack Overflow Oct 10, 2017 by havek

User contributions licensed under CC BY-SA 3.0