JaimeArturoB
New Member
- Joined
- Oct 4, 2021
- Messages
- 1
- Office Version
- 2019
- Platform
- Windows
I'm coding a menu in Excel VBA that retrieves the name of the workbook, a macro/function/userform on that workbook with iup to 5 arguments to pass in the command line.
These menu entries and code are on a separate and dedicated menu worksheet that can be reused for other applications while the macros and data reside in the other workbooks.
After processing the workbook name from a string variable into a workbook object, the resulting command line executers the remote function with the correct parameters being passed as shown below, where menuwb is the object for the workbook and menuSuborFuncName is the name of the remote function
Application.Run("'" & menuwb.Name & "'!" & menuSuborFuncName, menuArg1, menuArg2)
After a few hours searching everywhere for the correct syntax to equate this entry to the function's return variable, I found the small change needed to get the return value into a variable, as follows:
myReturnvar = Application.Run("'" & menuwb.Name & "'!" & menuSuborFuncName, menuArg1, menuArg2)
However, to keep this dynamic command line working for any menu entry on the table, I need the ability of using that single variable name to refer to the names and types of other variables for the rest of the code to work
Thus, if Menu A entry returns a Boolean named dupFound and Menu B returns a string of names called memberList,, is there a way in VBA to use/redirect/indirect both of those variables to MyRetrunvar.?
The only other option I'm considering is to store the entire command line with the correct variable name, but I'm no sure how to submit that for execution. The menuSuborFuncName, will be still dynamically substituted
dupfound = Application.Run("'" & menuwb.Name & "'!" & menuSuborFuncName, menuArg1, menuArg2)
memberlLst = Application.Run("'" & menuwb.Name & "'!" & menuSuborFuncName, menuArg1, menuArg2)
or I could store the entire separatecommand line item on each menu entry like this
dupfound = Application.Run("'" & WBObjName & "'!" & checkforDups "ABCD", "Sales"
memberList = Application.Run("'" & WBObjName2 & "'!" & getCustList "LA", "Boston"
what would be the syntax to run that command then?
Any suggestions?
These menu entries and code are on a separate and dedicated menu worksheet that can be reused for other applications while the macros and data reside in the other workbooks.
After processing the workbook name from a string variable into a workbook object, the resulting command line executers the remote function with the correct parameters being passed as shown below, where menuwb is the object for the workbook and menuSuborFuncName is the name of the remote function
Application.Run("'" & menuwb.Name & "'!" & menuSuborFuncName, menuArg1, menuArg2)
After a few hours searching everywhere for the correct syntax to equate this entry to the function's return variable, I found the small change needed to get the return value into a variable, as follows:
myReturnvar = Application.Run("'" & menuwb.Name & "'!" & menuSuborFuncName, menuArg1, menuArg2)
However, to keep this dynamic command line working for any menu entry on the table, I need the ability of using that single variable name to refer to the names and types of other variables for the rest of the code to work
Thus, if Menu A entry returns a Boolean named dupFound and Menu B returns a string of names called memberList,, is there a way in VBA to use/redirect/indirect both of those variables to MyRetrunvar.?
The only other option I'm considering is to store the entire command line with the correct variable name, but I'm no sure how to submit that for execution. The menuSuborFuncName, will be still dynamically substituted
dupfound = Application.Run("'" & menuwb.Name & "'!" & menuSuborFuncName, menuArg1, menuArg2)
memberlLst = Application.Run("'" & menuwb.Name & "'!" & menuSuborFuncName, menuArg1, menuArg2)
or I could store the entire separatecommand line item on each menu entry like this
dupfound = Application.Run("'" & WBObjName & "'!" & checkforDups "ABCD", "Sales"
memberList = Application.Run("'" & WBObjName2 & "'!" & getCustList "LA", "Boston"
what would be the syntax to run that command then?
Any suggestions?