0

So i am using this script to open an .xlsm and run a macro. The script runs fine aside from the fact that when the instance of excel is opened, it is without my usual add ins. Normally my excel opens fine with all my add-ins correctly installed.

Any ideas? thanks

'Input Excel File's Full Path
  ExcelFilePath = "C:\Myfolder\Myfile.xlsm"

'Input Module/Macro name within the Excel File
  MacroPath = "Module1.Mymacro"

'Create an instance of Excel
  Set ExcelApp = CreateObject("Excel.Application")

'Do you want this Excel instance to be visible?
  ExcelApp.Visible = True  'or "False"

'Prevent any App Launch Alerts (ie Update External Links)
  ExcelApp.DisplayAlerts = False

'Open Excel File
  Set wb = ExcelApp.Workbooks.Open(ExcelFilePath)

'Execute Macro Code
  ExcelApp.Run MacroPath

'Save Excel File (if applicable)
  wb.Save

'Reset Display Alerts Before Closing
  ExcelApp.DisplayAlerts = True

'Close Excel File
  wb.Close

'End instance of Excel
  ExcelApp.Quit

'Leaves an onscreen message!
  MsgBox "Task successfully ran at " & TimeValue(Now), vbInformation
davidh96
  • 1
  • 1
  • 1
    Does this answer your question? [Run Excel Macro from Outside Excel Using VBScript From Command Line](https://stackoverflow.com/questions/10232150/run-excel-macro-from-outside-excel-using-vbscript-from-command-line) – user692942 Oct 27 '21 at 08:50
  • Does this answer your question? [Force addin load in Excel /automation](https://stackoverflow.com/q/58592897) – user692942 Oct 27 '21 at 09:00
  • 1
    When used as an automation object (ie using CreateObject) from a different process, the system has to start an instance of Excel. But usually this instance does not load any addins by default (this is intended behaviour). Hence you may need to put explicit open commands for the addins you need: either in the Python code or at the start of the macro you want to run. – DS_London Oct 27 '21 at 09:39
  • @DS_London it's not Python it's VBScript but the same still applies. – user692942 Oct 27 '21 at 10:32

0 Answers0