I've found a few threads that are similar to what I'm trying to do, but I need to call a macro stored in an XLAM add-in.
I have an XLAM which contains custom add-in functions available to any Excel file. I am trying to call a macro within that XLAM. I am using the Workbooks.Add
rather than opening a specific file. Below is the code I'm using:
Option Explicit
RunMacro
Sub RunMacro()
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
xlApp.Run "C:\ATPBGC97\atpbgc2007.xlam\ExportModules"
xlApp.DisplayAlerts = False
xlBook.Saved = False
xlApp.ActiveWorkbook.Close
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
I used the thread Run Excel Macro from Outside Excel Using VBScript From Command Line to get this far. When I run the script, I get a 'Cannot run the macro' error. I'm not exactly sure what the syntax should be in my case or if I should just open a dummy file to gain access to the XLAM.