Forum Discussion
- Marsha_R
Champion Level 3
Where in the code does the error show up?
- NitishOccasional Contributor
FileName = "Path of the file "
intCount = 0
'set Objdriver = DDT.ExcelDriver(FileName , SheetName)
set objdriver = DDT.ExcelDriver(FileName ,SheetName,)//here it shows
' do While not(objdriver.EOF())//here it shows
' intCount = intCount+1
' objdriver.Next()
' loop
While not(objdriver.EOF())
- Ryan_MoranValued Contributor
Can you post a snippet of your code so we can see exactly how you are using the driver?
- NitishOccasional Contributor
FileName = "Path of the file "
intCount = 0
'set Objdriver = DDT.ExcelDriver(FileName , SheetName)
set objdriver = DDT.ExcelDriver(FileName ,SheetName,)
' do While not(objdriver.EOF())
' intCount = intCount+1
' objdriver.Next()
' loop
While not(objdriver.EOF())
intCount = intCount+1
objdriver.Next()
Wend
DDT.CloseDriver(objdriver.Name)
redim arrInput(intRecCount)
set objdriver = DDT.ExcelDriver(FileName , SheetName,true)
for LoopCount = 0 to intRecCount-1
if IsNull(DDT.CurrentDriver.Value(intColumnNo)) then
ArraySize = LoopCount - 1
exit For
Else
arrInput(LoopCount) = VarToStr(DDT.CurrentDriver.Value(intColumnNo))
objdriver.Next()
ArraySize = intRecCount
end if
next
DDT.CloseDriver(objdriver.Name)
redim arrdata(ArraySize)
for LoopCount1 = 0 to UBound(arrdata)
arrdata(LoopCount1) = arrInput(LoopCount1)
nextReadExcel = arrdata
End Function- Ryan_MoranValued Contributor
Try this:
FileName = "Path of the file " intCount = 0 'set Objdriver = DDT.ExcelDriver(FileName , SheetName) Set objdriver = DDT.ExcelDriver(FileName ,SheetName) ' do While not(objdriver.EOF()) ' intCount = intCount+1 ' objdriver.Next() ' loop While not(objdriver.EOF()) intCount = intCount+1 objdriver.Next() Wend DDT.CloseDriver(objdriver.Name) redim arrInput(intRecCount) Set objdriver = DDT.ExcelDriver(FileName ,SheetName) For LoopCount = 0 To intRecCount-1 if IsNull(DDT.CurrentDriver.Value(intColumnNo)) then ArraySize = LoopCount - 1 exit For Else arrInput(LoopCount) = VarToStr(DDT.CurrentDriver.Value(intColumnNo)) objdriver.Next() ArraySize = intRecCount End If Next DDT.CloseDriver(objdriver.Name) redim arrdata(ArraySize) For LoopCount1 = 0 To UBound(arrdata) arrdata(LoopCount1) = arrInput(LoopCount1) Next ReadExcel = arrdata End Function
- NitishOccasional Contributor
Thankyou ryan for Replying
but the above code is throwing the same error .
An attempt to work with closed driver.
- NitishOccasional Contributor