Search code examples
excelvbavbscriptavaya

.acsauto script to open Excel application and call macro


Each morning I use an Avaya CMS Supervisor script file (.acsauto) to generate a bunch of very simple Excel files, then I have another macro enabled Excel file that I use to compile the multiple files' data into one nice reporting view.

I noticed that the acsauto file is written in visual basic, so I've been trying to see if I can add to the end of that script to have it go ahead and open the xlsm file for me and call the macro that compiles everything. Unfortunately I'm getting an error message "Expected end of statement", starting at this line:

Dim xlApp as Excel.Application
Set xlApp = New Excel.Application
xlApp.Visible = true
xlApp.Application.Workbooks.Open ("C:\folders\file name.xlsm")
xlApp.Application.Run ("'file name.xlsm'!MacroName")

Other parts of the script have Dim something without any as something part, so I tried removing as Excel.Application in this section too. After that the script doesn't throw any errors, but it also doesn't open Excel, so I'm not really any closer to a solution.

Any suggestions would be gladly received.


Solution

  • Dim xlApp
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = true
    xlApp.Application.Workbooks.Open ("C:\folders\file name.xlsm")
    xlApp.Application.Run ("'file name.xlsm'!MacroName")