Forum Discussion

rhsou123's avatar
rhsou123
Contributor
8 years ago

How to use Excel data using DDT driver without keeping the Excel file open ?

Hi all,

 

I'm using DDT driver to get my Excel data but If my Excel file is closed this doesn't work correctly,

 

How to solve this please ?

 

set xlDriver = DDT.ExcelDriver("C:\Script-Resources\myfile.xls","Sheet1",false)
 xlDriver.First
 
while not xlDriver.EOF

....................

xlDriver .Next
Wend

13 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Hi,

     

    What exactly did you mean saying "doesn't work correctly"? Did you receive any kind of error?

    • rhsou123's avatar
      rhsou123
      Contributor

      I'm defining two DDT drivers, the first one works correctly even if my Excel file is closed and the second one if my file is open it works too but if it is closed, Testcomplete waits for a long time without executing anything as if it is not getting the Data from the Excel sheet.

       

      this is my code:

       

      set xlDriver = DDT.ExcelDriver("C:\Script-Resources\BatchRun\myfile.xls","Sheet1",True)
       xlDriver.First
       
      while not xlDriver.EOF
      value1= xlDriver.Value("x")
      value2= UCase(xlDriver.Value("y"))
      if value1= "Y" then 
      
      		
      			value3 = xlDriver.Value("z") 
      			value4= xlDriver.Value("t")
            
            If value2= "ENVIRONMENT_SET" Then
           
      				value5= value2
               BuiltIn.ShowMessage( value5)
               	Else
                
      				If value5="" Then
      					call Basic.myfunction()
      
      					ExitTest
      				Else
      
       set xlDriver1 = DDT.ExcelDriver(C:\Script-Resources\BatchRun\myfile2.xls,"BatchRun",True)
             xlDriver1.First
             while not xlDriver1.EOF
             value6= xlDriver1.Value("xx")
              if value6= "Y" then
      		
      						value7= xlDriver1.Value("yy")	
      						value8= xlDriver1.Value("tt")

       

       

      • baxatob's avatar
        baxatob
        Community Hero

        In the second case you are passing third parameter as True. This should use ACE Driver instead of ODBC:

         

         

        1st case: set xlDriver = DDT.ExcelDriver("C:\Script-
            Resources\BatchRun\myfile.xls","Sheet1",false)
        
        2nd case: set xlDriver1 = DDT.ExcelDriver(C:\Script-
            Resources\BatchRun\myfile2.xls,"BatchRun",True)

         

        Why you are doing so? Try to change it to False.