Update: The code is working fine now after adding this:
Do While ie.Busy Or ie.readyState <> 4: DoEvents: Loop
Thank you.
Originally Posted by
Norie
Why not just submit the form?
Without seeing the rest of your code I can only guess but something like this might work.
Hi Norie,
Thank you for the reply and apologize for the late reply. Was away to overseas.
I do not know how to submit the forms... would you be able to help me?
Below is my code:
Sub GetOptionData()
Dim ie As internetexplorer
Dim html As HTMLDocument
Dim myURL As String
On Error GoTo Err_Clear
myURL = Range("myURL")
'/ 1st page
'/ Open Internet Explorer in memory go to website
'/ Wait until IE has loaded the web page
Set ie = New InternetExplorerMedium
With ie
.Visible = True
.navigate "myURL"
Do Until .readyState = 4: DoEvents: Loop
End With
'/ Web page loaded completely, define variables
Set html = ie.document
'/ Automate drop down list
'/ Select region from drop down
Dim drp As HTMLFormElement
Set drp = html.getElementById("regionid")
drp.selectedIndex = 1 '/ select region - 0 Europe, 1 JAPA
Do Until ie.readyState = 4: DoEvents: Loop
'/ Declares variables after region is selected and webpage loaded completely
Dim html_element As IHTMLElement
Dim html_filter As HTMLDocument
'/ Look for Select button and automate click
Set html_filter = ie.document
For Each html_element In html_filter.getElementsByTagName("input")
If html_element.Type = "submit" Then html_element.Click: Exit For
Next html_element
Do Until ie.readyState = 4: DoEvents: Loop
Err_Clear:
If Err <> 0 Then Err.Clear
Resume Next
'/ Releases memory
Set ie = Nothing
End Sub
Thank you!
HC
Bookmarks