Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript only runs parts of excel macro

Status
Not open for further replies.

badAtCode

Systems Engineer
Aug 15, 2017
1
0
0
CA
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.

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.
 
hi,

Plz post the TransferData procedure from Excel VBA.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top