Hi,
I have the below which logs me into the website I want succesfully. However, once I am logged in I want to navigate to another page to which I have provided the link for. However, the macro just sits on the page you get after I log in. Have I done something wrong in the code?
Public Sub Launch1()
Dim ieApp As InternetExplorer
Set ieApp = New InternetExplorer
Const strURL_c As String = "http://www.entermywebsitehere.com"
Const strUsr_c As String = "entermyusernamehere"
Const strPwd_c As String = "entermypasswordhere"
Dim objIE As SHDocVw.InternetExplorer
Dim ieDoc As MSHTML.HTMLDocument
Dim tbxPwdFld As MSHTML.HTMLInputElement
Dim tbxUsrFld As MSHTML.HTMLInputElement
Dim btnSubmit As MSHTML.HTMLInputElement
On Error GoTo Err_Hnd
'Create Internet Explorer Object
Set objIE = New SHDocVw.InternetExplorer
'Navigate the URL
objIE.navigate strURL_c
'Wait for page to load
Do Until objIE.readyState = READYSTATE_COMPLETE: Loop
'Get document object
Set ieDoc = objIE.document
'Get username/password fields and submit button.
Set tbxPwdFld = ieDoc.all.Item("password")
Set tbxUsrFld = ieDoc.all.Item("username")
Set btnSubmit = ieDoc.all.Item("OK")
'Fill Fields
tbxUsrFld.Value = strUsr_c
tbxPwdFld.Value = strPwd_c
'Click submit
btnSubmit.Click
'Wait for page to load
Do Until objIE.readyState = READYSTATE_COMPLETE: Loop
Err_Hnd: '(Fail gracefully)
objIE.Visible = True
'now that we’re in, go to the page we want (the thing is my macro doesnt seem to run this bit)
ieApp.navigate "https://www.entermywebsitehere.com/nextpage/SystemMain.php?page=mon&spid=1&realcategoryid=31&tou33"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.readyState = READYSTATE_COMPLETE: DoEvents: Loop
End Sub
Bookmarks