How to Use Excel file with DDT driver in code ,without opening the excel file
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to Use Excel file with DDT driver in code ,without opening the excel file
When I try to access excel with DDT driver ,with Excel file open ,code is working fine , but as soon as I run code the with excel file closed ."An attempt to work with closed driver ".Is there any workArround that I can use to run the code without opening the excel file
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you post a snippet of your code so we can see exactly how you are using the driver?
''-Praise the sun and Give Kudos.''
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Where in the code does the error show up?
Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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())
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
''-Praise the sun and Give Kudos.''
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thankyou ryan for Replying
but the above code is throwing the same error .
An attempt to work with closed driver.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
''-Praise the sun and Give Kudos.''
