I'm trying to make VBScript run a macro (TransferData) in an already-opened excel workbook (Master File). The excel macro will SaveAs the already-open file to another name, opens a file containing data, and copy/pastes that data into the already-open file. The macro works as intended when I manually run it within excel; however, when I try through VBScript it only executes the SaveAs portion of the macro.
Like I said, the macro runs as intended when I click "run macro" inside excel. So I was thinking it had to be something VBScript was doing that would not allow the macro to completely execute its commands. I tried a sleep-like function because I thought the Master File was being closed before the macro was fully executed; however, that did not solve the issue.
Code:
Sub Work()
Set objExcel = GetObject(, "Excel.Application")
objExcel.Application.Run "'C:\Users\Me\Desktop\Master File.xlsm'!TransferData"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
End Sub
Like I said, the macro runs as intended when I click "run macro" inside excel. So I was thinking it had to be something VBScript was doing that would not allow the macro to completely execute its commands. I tried a sleep-like function because I thought the Master File was being closed before the macro was fully executed; however, that did not solve the issue.