0

The vbscript below is intended to trigger a macro named "Test" in the file listed in the script. It follows examples I've seen on this site, but it does not run the macro. Probably a syntax issue. Maybe related to the desktop where the file is. Any help is appreciated.


On Error Resume Next

ExcelMacroExample

Sub ExcelMacroExample() 

  Dim xlApp 
  Dim xlBook


  Set xlApp = CreateObject("Excel.Application")
  Set xlBook = xlApp.Workbooks.Open("C:\Users\smithj01\Desktop\Alteryx Demo\'Command Line Test.xlsm'", 0, True)  
  xlApp.Run "Test"
  xlApp.Quit 

  Set xlBook = Nothing 
  Set xlApp = Nothing
  Set objFSO = Nothing 

End Sub
user692942
  • 16,398
  • 7
  • 76
  • 175
Brad Lee
  • 187
  • 1
  • 10
  • Do not use `On Error Resume Next` unless you absolutely have to. It will swallow all errors so you cannot tell where an error occurs. Remove that line and run your code again to see where it fails. – Rno Sep 17 '19 at 23:11
  • Possible duplicate of [Use vbs to open an excel workbook, run a macro and save the workbook](https://stackoverflow.com/questions/29325804/use-vbs-to-open-an-excel-workbook-run-a-macro-and-save-the-workbook) –  Sep 18 '19 at 06:00
  • I see you are Running the macro and killing the excel but not saving it. Use xlApp.Save before xlApp.quit and it should save the changes in the excel done by macro. Also open the macro in read write mode. May be this should do the trick. – Sandeep jaju Sep 18 '19 at 06:47

0 Answers0