I'm trying a VBScript that should open Excel, open a workbook, run a macro and then close everything.
Dim objExcel, xlBook
Set objExcel = CreateObject("Excel.Application")
Set xlBook = objExcel.Workbooks.Open ("path to the xlsm file")
objExcel.Visible = True
objExcel.Run xlBook.name & "!Modulo1.Macro1"
WScript.Sleep 20000
objExcel.Quit
Everything works fine, Excel opens the .xlsm file and runs the macro, but then after closing the workbook (this is included in the macro) Excel remains opened.
It seems objExcel.Quit
doesn't work correctly.
I'm working with Excel 2016 in Windows 7.
These are the last lines of the macro:
Application.DisplayAlerts = False
ChDir "C:\Users\" & UserName & "\Google Drive\Shopify"
ActiveWorkbook.SaveAs Filename:= "C:\Users\" & UserName & _
"\Google Drive\Shopify\Shopify.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Workbooks("Shopify.xlsx").Close
End Sub
Application.DisplayAlerts = False
toTrue
- Excel might be popping up a message to save your changes or displaying an error dialog box – dbmitch