bmcelroy7
asked on
Excel VBA: Login to website
I need to connect an excel spreadsheet to a website that requires login credentials. I have seen a few threads that discuss these but were unable to follow. Could provide how I would go about logging in to "https://www.dinersclub.com/ptl/login.do"? My ultimate goal would be to login and obtain statements and dump them into excel but maybe piece mealing would be best for now.
Thanks,
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry jeverist...I should have refreshed first. I didn't try yours yet...but looks good!
I would like to know what Document.All actually means though. Does that like look for any element on any form with the name that you put in double quotes??
How does it know which element to use if there were 2 different forms with elements of the same name?? I am not a web page designer at all! so maybe you can't have 2 different forms with elements of the same name. I don't know. I'm just trying to understand your code a little better.
:-)
ah
I would like to know what Document.All actually means though. Does that like look for any element on any form with the name that you put in double quotes??
How does it know which element to use if there were 2 different forms with elements of the same name?? I am not a web page designer at all! so maybe you can't have 2 different forms with elements of the same name. I don't know. I'm just trying to understand your code a little better.
:-)
ah
Here is the code. After you put it in a module...run the LogIn macro:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Sub LogIn()
Dim oIE As Object
Set oIE = CreateObject("InternetExpl
oIE.Visible = True
oIE.Navigate ("http://www.dinersclubus.com/dce_content/home")
While oIE.Busy
Sleep 2000
Wend ' wait for page to load...
Sleep 500
SetForegroundWindow (oIE.hwnd)
If Not oIE.Document.Forms(1).Elem
oIE.Document.Forms(1).Elem
oIE.Document.Forms(1).Elem
oIE.Document.Forms(1).Elem
End If
Sleep 100
oIE.Document.Forms(1).subm
End Sub
:-)
ah