Tuesday, January 6, 2015

Using Excel as Database

Option Explicit
Dim objConn,objRS
 
Set objConn = CreateObject("ADODB.Connection") 
Set objRS = Createobject("ADODB.Recordset")

objConn.Open "Driver={Microsoft Excel Driver (*.xls),(*.xlsx)(*.xlsm),(*.xlsb)};DBQ=C:\USERS\Desktop\FileName.xlsx;"
objRS.Open "Select [UN],[PW] FROM [TABLE1$]", objConn

Do while not objRS.EOF
 Browser("Gmail").WebEdit("username").Set objRS.FIELDS("UN")
 Browser("Gmail").WebEdit("password").Set objRS.FIELDS("PW")
 Browser("Gmail").WebBotton("LogIn").CLICK
 objRS.MOVENEXT
Loop

'Release created objects
Set objRS= NOTHING
Set objConn= NOTHING


Note: The database we are using here is MS Excel2007(*.xlsx). Create a table/sheet name in MS Excel2007 called "TABLE1" and column 'names as "UN" and "PW" and path of the table which we create is C:\USERS\Desktop\FileName.xlsx. 

No comments:

Post a Comment