использовать аналогичную логику из Запуск макроса Excel из SSIS
В SSIS логика задачи «Мой сценарий» следующая,
public void Main()
{
// TODO: Add your code here
string filename;//= Dts.Variables["User::filename"].Value.ToString();
filename = @"D:\VersionWithDummyData\finbalReviewTest.xlsm";
string S_Directory = @"D:\VersionWithDummyData\";
if (S_Directory.Substring(S_Directory.Length - 1, 1) != @"\")
{
S_Directory = S_Directory + @"\";
}
DirectoryInfo finfo = new DirectoryInfo(S_Directory);
if (filename.ToString().Substring(1, 2) != "~$")
{
try
{
xls.Application ExcelObj = new xls.Application();
ExcelObj.DisplayAlerts = true;
ExcelObj.Visible = true;
ExcelObj.DefaultFilePath = S_Directory;
xls.Workbook eBook = ExcelObj.Workbooks.Open(filename.ToString(), false, false,
Type.Missing, "", "", true, xls.XlPlatform.xlWindows, "",
false, false, 0, false, true, 0);
foreach (xls.WorkbookConnection wc in eBook.Connections)
{
if (wc.Type.ToString() == "xlConnectionTypeODBC")
{
wc.ODBCConnection.BackgroundQuery = false;
}
else
{
wc.OLEDBConnection.BackgroundQuery = false;
}
}
eBook.RefreshAll();
eBook.Save();
ExcelObj.Run("Module1",Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
eBook.Save();
ExcelObj.Workbooks.Close();
ExcelObj.Quit();
}
catch (COMException e)
{
MessageBox.Show(filename.ToString() + " has an issue with error " + e.Message);
}
}
Dts.TaskResult = (int)ScriptResults.Success;
}
И макросы, доступные в Excel (.xlsm), выглядят следующим образом
Sub fileSave()
'
Dim newFileName As String, originalFileName As String, fileSaveName As String, fileNamePathSaved As String, fileNameSaved As String
Dim response As VbMsgBoxResult, currentRoute As String
'
ThisWorkbook.RefreshAll
ActiveWorkbook.Save ' save the current workbook before messing with it
Application.DisplayAlerts = False ' turns off alerts and messages
' Save file name and path into a variable
originalFileName = ActiveWorkbook.FullName ' gets the fullname with path
' originalFilePath = ActiveWorkbook.Path ' grabs the current path
Dim usingReplace As String
usingReplace = Replace(originalFileName, ".xlsm", ".xlsx")
ActiveWorkbook.SaveAs Filename:=usingReplace, FileFormat:=xlOpenXMLWorkbook
fileNameSaved = ActiveWorkbook.Name ' grabs the name of the saved file
Workbooks.Open Filename:=originalFileName 'reopens the original workbook file
Application.DisplayAlerts = True ' turns the alerts and messages back on
'provide an opportinity to clear the incident report flag
' If incidentFiled = True Then response = MsgBox("Do you want to clear the Incident Report?", vbInformation + vbOKCancel, "Incident Report Form")
If response = vbOK Then incidentFiled = False
'close the newly made file
' Workbooks(fileNameSaved).Close True ' sub terminates at this point
'
End Sub
вышеупомянутые макросы сохраняются как Module1, когда я пытаюсь запустить пакет, данные обновляются, но макросы не выполняются
Примечание: Перепробовал все решения, предложенные в аналогичном посте

перебор все же ошибка это ошибка произошла
Важно:
* макросы при попытке выполнить из Excel -> Developer -> Visual *** -> Module1 -> execute, затем работают должным образом. *