In a VB6 application I’m developing, I need to open a number of Excel spreadsheets and kick off the VBA within them. As they also stand alone, they do this by opening a Login form to gather userid and password, then start a macro (always the same name). Currently, this multiple opening etc is performed via another spreadsheet, which gathers the userid and password, then loops to open the spreadsheets and execute them thus:
Workbooks.Open ThisWorkbook.ActiveSheet.Cells(intCellsDown, 2), False, False, , , , True
ActiveWorkbook.RunWorkbook ConstLogin, ConstPass
ActiveWorkbook.Close True
where RunWorkbook is the standard subroutine in each spreadsheet, and ConstLogin and ConstPass are the parameters. This works fine.
But in VB6….? I can see how to execute RunWorkbook; various sites suggest either:
appExcel.Run “RunWorkbook”
or
appExcel.ExecuteExcel4Macro “RunWorkbook”
but nowhere can I find a way of passing the parameters into the spreadsheets from the VB6 application. Adding them to the end of the methods above doesn’t work, usually provoking a “too many arguments” error, and I can’t think of another way! Any suggestions?
TIA