excel 求助 ExecuteExcel4Macro取数返回值为0

rogerjh 2017-06-28 02:06:23
为什么用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
...全文
1004 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧