我正在使用下面的代码从已关闭的工作簿中检索一个数字。返回正确的MsgBox
值,但我无法将该数字分配给我的modelVersion
变量,也不明白为什么会这样。如果有人可以帮助我,我将不胜感激,因为我认为该ExecuteExcel4Macro
方法可能不能以这种方式使用?
Public Sub checkModelVersion()
Dim wbPath As String, wbName As String
Dim wsName As String, cellRef As String
Dim Ret As String
wbPath = "C:\mypath\"
wbName = "Update.xlsm"
wsName = "Dashboard"
cellRef = "E7"
Ret = "'" & wbPath & "[" & wbName & "]" & wsName & "'!" & Range(cellRef).Address(True, True, -4150)
MsgBox ExecuteExcel4Macro(Ret)
modelVersion = ExecuteExcel4Macro(Ret)
End Sub