N
Neal Zimm
Hi -
I don't know where to go next in getting the value to return from a Sub
executed from one Wbk to another.
I got The function to return the correct value.
Running the Sub gets the correct debug.print, But the returned argument is
either the same as the function or blank in the final examples below.
Why ?
Thanks,
Neal
' IN 1125 Wbk, Which is ACTIVE
Function zRmVerF(Dummy) As String
zRmVerF = "v01.03.00"
Debug.Print zRmVerF
End Function
'Sub in same as above
Sub zRmVerSub(Ver As String)
Ver = "vRm.Ver.Sub"
Debug.Print Ver
End Sub
' executed from VBE in personal.xls
Sub RUN_MACRO_WAYS()
Dim Ver As String, MacName As String
'Ver = Application.Run("'d1125.xls'!zRmVerF", "")
'MsgBox Ver 'WORKS prints and value passed
Dim WbkNa As String
WbkNa = ActiveWorkbook.Name
MacName = "zRmVerF"
Ver = Application.Run(WbkNa & "!" & MacName, "")
MsgBox Ver 'WORKS prints and value passed
MacName = WbkNa & "!" & "zRmVerSub"
'Application.Run (MacName, Ver) ??? compile error: Expected: =
'Application.Run MacName, Ver 'debug.print good,
'MsgBox Ver 'shows v01.03.00 from function, NOT vRm.Ver.Sub as expected
Dim DiffVer As String
Application.Run MacName, DiffVer 'debug.print is good
MsgBox DiffVer, , "DiffVer" 'no value for DiffVer ???
End Sub
I don't know where to go next in getting the value to return from a Sub
executed from one Wbk to another.
I got The function to return the correct value.
Running the Sub gets the correct debug.print, But the returned argument is
either the same as the function or blank in the final examples below.
Why ?
Thanks,
Neal
' IN 1125 Wbk, Which is ACTIVE
Function zRmVerF(Dummy) As String
zRmVerF = "v01.03.00"
Debug.Print zRmVerF
End Function
'Sub in same as above
Sub zRmVerSub(Ver As String)
Ver = "vRm.Ver.Sub"
Debug.Print Ver
End Sub
' executed from VBE in personal.xls
Sub RUN_MACRO_WAYS()
Dim Ver As String, MacName As String
'Ver = Application.Run("'d1125.xls'!zRmVerF", "")
'MsgBox Ver 'WORKS prints and value passed
Dim WbkNa As String
WbkNa = ActiveWorkbook.Name
MacName = "zRmVerF"
Ver = Application.Run(WbkNa & "!" & MacName, "")
MsgBox Ver 'WORKS prints and value passed
MacName = WbkNa & "!" & "zRmVerSub"
'Application.Run (MacName, Ver) ??? compile error: Expected: =
'Application.Run MacName, Ver 'debug.print good,
'MsgBox Ver 'shows v01.03.00 from function, NOT vRm.Ver.Sub as expected
Dim DiffVer As String
Application.Run MacName, DiffVer 'debug.print is good
MsgBox DiffVer, , "DiffVer" 'no value for DiffVer ???
End Sub