Forum Discussion

ryanshoward's avatar
ryanshoward
Occasional Contributor
9 years ago
Solved

DDT Driver Getting data from specific row VBscript

Hi,

 

I'm trying to use the DDT driver to grab some login details from an xlsx file but I'm having issues when using

While Not DDT.CurrentDriver.EOF

Here is my code

Sub GetUsername_Password
Dim Driver
' Creates a driver
Set Driver = DDT.ExcelDriver("C:\LoginDetails\loginDetails.xlsx", "Sheet1",true)

 While Not DDT.CurrentDriver.EOF
 DDT.CurrentDriver.Next
      
 If DDT.CurrentDriver.Value("Permissions")= "Write" Then
  log.Message "Found"
  else
  log.Message "Not found"
 
  End If
       
        WEnd
  DDT.CloseDriver(DDT.CurrentDriver.Name)
 
  
End Sub

 

Basically I want to do the following:

Open up the excel file

find the column "Permissions"

Locate the cell "Write"

output the username and password for "write" - I havent added this part yet

 

The problem I'm having is that when i run this I get an error stating

 

'Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record'

 

If I comment Out the line 'While Not DDT.CurrentDriver.EOF ' it finds the cell "Write", but it wont then find the cell "Read" if I want it to.

 

How do I code it so It will find any cell in the permissions column when i specify it in the If statement?

 

Apologies if I have made any obvious mistakes I'm new to vbs. I've attached my sample file

 

Please help

 

Thanks,

Ryan

 

 

 

 

 

 

 

 

 

  

  • The Next() call needs to be at the end of your loop, not the beginning.