Не удается запустить макрос ...макрос может быть недоступен в рабочей книге или все маркро могут быть отключены
"Cannot run the macro ...The macro may not be available in the workbook or all marcros may be disabled"<pre> oExcel = CreateObject("Excel.Application") oExcel.Visible = False oBooks = oExcel.Workbooks oBook = oBooks.Open(Dts.Variables("filePath").Value.ToString()) //Your macro here: oExcel.Run("Yourmacro") I have used the above logic in SSIS package, every thing went fine but macros was not running and the result was the above error My macro name is "Module1"
макрос выглядит следующим образом
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
заранее спасибо
Что я уже пробовал:
oExcel = CreateObject("Excel.Application") oExcel.Visible = False oBooks = oExcel.Workbooks oBook = oBooks.Open(Dts.Variables("filePath").Value.ToString()) //Your macro here: oExcel.Run("Module1")