So my problem is that I can't get the VBScript to work. I want to automate this macro using the VBScript written in this post, which should execute the VBA code below. The error message I receive is in line 2, where the error is that the file couldn't be found. The VBScript and the test.xlsm file is in the same folder. How can I access the test.xlsm file without an error?
My VBA code so far:
Sub copySchedule()
Worksheets("Sheet2").Range("B2:F10").Copy Worksheets("Sheet1").Range("B2:F10")
ActiveWorkbook.Save
End Sub
My VBScript code so far:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("test.xlsm")
objExcel.Application.Run ""test.xlsm!copySchedule""
objExcel.Application.Quit
WScript.Quit
objExcel.Application.Run "test.xlsm!copySchedule"Workbooks.Opencall