|
楼主 |
发表于 2014-11-20 11:42
|
显示全部楼层
Private Function GetValue(path, filename, sheet, ref)
' 从关闭的工作薄返回值
Dim MyPath As String
'确定文件是否存在
If Right(path, 1) < > "\" Then path = path & "\"
If Dir(path & filename) = "" Then
GetValue = "无法找到指定的Excel文件"
Exit Function
End If
'创建公式
MyPath = "'" & path & "[" & filename & "]" & sheet & "'!" & Range(ref).Range("A1").Address(, , xlR1C1)
'执行EXCEL4宏函数
GetValue = Application.ExecuteExcel4Macro(MyPath)
End Function
'函数参数说明
'-----------------------------------------------------------------
'path:文件路径
'filename:文件名称
'sheet:工作表名称
'ref: 单元格区域
'-----------------------------------------------------------------
Sub GetCloseXlsValue()
Range("C3").Value = GetValue("F:\", "成绩表.xls", "Sheet1", "E8")
End Sub
这个众网上下的,但是做实验的的时候,不行, |
|