Rugbyleary
New Member
- Joined
- Jul 31, 2015
- Messages
- 1
Hello,
I am working on a project where I need to pull data from a website. The website requires that I sign in using a username, which I have already done. I then get taken to a landing "Home" page, but I need to navigate from that page to my desired webpage. From there I need to scrap the information and enter it into an existing excel file. For now, I'd like some help to navigate from the homepage to my desired webpage. Here is what I've done already:
Below is the code that has worked thus far:
Private Sub GetData_Click()
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "http://oxlive.dorseywright.com/login?c=FCC"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
HTMLDoc.all.Email.Value = "004jdje" 'Enter your email id here
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
While IE.readyState <> 4
DoEvents
Wend
End Sub
Now I need to navigate to a web page within this website and I'm stuck. I am new to the VBA world so my knowledge is incomplete but any help is greatly appreciated. Thank you!
Taylor
I am working on a project where I need to pull data from a website. The website requires that I sign in using a username, which I have already done. I then get taken to a landing "Home" page, but I need to navigate from that page to my desired webpage. From there I need to scrap the information and enter it into an existing excel file. For now, I'd like some help to navigate from the homepage to my desired webpage. Here is what I've done already:
- Set controls for IE
- Create Button in excel to initiate the VBA request
- Written code to open IE and sign onto desired website (See below)
- Opens website and takes me to the "Home" page
Below is the code that has worked thus far:
Private Sub GetData_Click()
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "http://oxlive.dorseywright.com/login?c=FCC"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
HTMLDoc.all.Email.Value = "004jdje" 'Enter your email id here
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
While IE.readyState <> 4
DoEvents
Wend
End Sub
Now I need to navigate to a web page within this website and I'm stuck. I am new to the VBA world so my knowledge is incomplete but any help is greatly appreciated. Thank you!
Taylor