excel 求助 ExecuteExcel4Macro取数返回值为0
为什么用ExecuteExcel4Macro,执行后返回的值一直为空?
代码如下,是编写function中存在问题么?
Public Function Getvalue(path, file, sheet, ref)
Dim arg As String
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
Getvalue = "File Not Found"
Exit Function
End If
arg = "'" & path & "[" & file & "]" & sheet & "'!" & Range(ref).Address(, , xlR1C1)
Getvlaue = ExecuteExcel4Macro(arg)
End Function
Sub TestGetValue()
p = ThisWorkbook.path
f = "ABC.XLS"
s = "sheet1"
Application.ScreenUpdating = False
For r = 1 To 100
For c = 1 To 12
a = Cells(r, c).Address
Cells(r, c) = Getvalue(p, f, s, a)
Next c
Next r
Application.ScreenUpdating = True
End Sub