Public Function GetCellValue(strPath, strFile, strSheet, strA1)
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
If Dir(strPath & strFile) = "" Then '判断文件是否存在
'文件不存在时产生运行时错误,此错误会传递给调用此函数的过程
Err.Raise 12345, "GetCellValue", "No found file"
Exit Function
End If
'调用XLM4.0宏表函数读取指定区域的内容
'如果指定工作表不存在,返回错误
GetCellValue = ExecuteExcel4Macro("'" & strPath & "[" & strFile & "]" _
& strSheet & "'!" & Range(strA1).Address(, , xlR1C1))
End Function
Excel VBA 不打开Excel文件访问其中内容的方法
最新推荐文章于 2023-09-28 11:07:45 发布