求助,VBS统计Excel行数时报下标越界
Dim fileSystemObj,fileSpecDim currentDate,currentTime
currentDate = Date
currentTime = Time
testName = environment.Value("TestName")
Set fileSystemObj = CreateObject("excel.Application")
fileSpec = Test_path&"测试记录\"&testName&".xlsx"
Set logFile = fileSystemObj.Workbooks.Open(fileSpec)
Set logSheet = fileSystemObj.Worksheets.Add
DataSpec=Test_path&"测试数据\"&"data.xls"
Set Datasheet = fileSystemObj.Workbooks.Open(DataSpec)
i=Datasheet.Worksheets(testName).usedrange.Rows.count——下标越界 第一:QTP只能加载xls格式的excel,即使2007之前的版本不包含2007,所以fileSpec = Test_path&"测试记录\"&testName&".xlsx"需要修改成fileSpec = Test_path&"测试记录\"&testName&".xls"
第二:Datasheet.Worksheets(testName).usedrange.Rows.count,其中testName表示excel中的sheet,这个sheet必须存在
页:
[1]