Forum Discussion
Ryan_Moran
9 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
Nitish
9 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.
- Ryan_Moran9 years agoValued Contributor
If this is the case then reboot your PC and try again.
If it works for a period of time after rebooting then you have an issue with the driver not being closed properly.
- Marsha_R9 years ago
Champion Level 3
We had Close Driver issues so I just quit using the close. Probably bad practice but it works. :smileyhappy: