Forum Discussion
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)
next
ReadExcel = arrdata
End Function
- Ryan_Moran9 years agoValued 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
- Nitish9 years agoOccasional Contributor
Thankyou ryan for Replying
but the above code is throwing the same error .
An attempt to work with closed driver.- Colin_McCrae9 years agoCommunity Hero
Not sure if yours is the same problem, but this was raised, and solved, on here before:
Was down to trying to open too many connections .....
And also here:
Where it was down to drivers.