标题: 【已解决】用QTP打开EXCEL文件报错 [打印本页] 作者: gold_85 时间: 2010-2-3 08:44 标题: 【已解决】用QTP打开EXCEL文件报错 Dim xl
'打开excel文件
Function OpenExcelFile(strFilePath)
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open strFilePath
End Function
Call OpenExcelFile("c:\test.xls")
运行时提示 类 Workbooks 的 Open 方法无效
[ 本帖最后由 yujie6832 于 2010-2-3 12:08 编辑 ]作者: yujie6832 时间: 2010-2-3 09:41
Public Function ReadExcelContent(filename,sheetname,row,column)
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelBook = ExcelApp.Workbooks.Open (filename)
Set ExcelSheet = ExcelBook.Worksheets.Item(sheetname)
ReadExcelContent = ExcelSheet.cells(row,column)
ExcelBook.Close
ExcelApp.Quit
Set ExcelSheet = Nothing
Set ExcelBook = Nothing
Set ExcelApp = Nothing
End Function