lacemagic
12-15-2015, 09:05 AM
I am trying to automate the filling of a form, clicking submit, and then after that, clicking another button on the second page. My code so far successfully fills out the form and clicks the button loading the second page. However, on the second page I cannot get the button to click. When stepping through the code it clicks the second page button so I have properly identified the button but it is like the webpage is no longer selected when the code is running. Any help?
The Button on the second webpage page:
<tr><th colspan='3' style='padding-top:23px;padding-bottom:10px'><input type='button' value='Continue' class='v14b' onclick='if(verFrm())document.form1.submit();'></tr>
My code to open the first webpage, fill out necessary forms, and click the button. Then to click the button on the next page.
Sub FillICEForm()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "website"
ie.Visible = True
While ie.busy
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:02"))
ie.document.ALL("sf").Value = "1"
ie.document.ALL("sd").Value = "100"
ie.document.ALL("cd").Value = "100" 'sd/sf
ie.document.ALL("ci").Value = "100"
ie.document.ALL("r").Value = "100"
ie.document.ALL("st").Value = "2" 'FROM SHEET
'Submit first form
Set the_input_elements = ie.document.getElementsByTagName("input")
For Each input_element In the_input_elements
If input_element.getattribute("class") = "v14b" Then
input_element.Click
Exit For
End If
Next input_element
'Second page
Set the_input_elements = ie.document.getElementsByTagName("input")
For Each input_element In the_input_elements
If input_element.getattribute("value") = "Continue" Then
input_element.Click
Exit For
End If
Next input_element
End Sub
The Button on the second webpage page:
<tr><th colspan='3' style='padding-top:23px;padding-bottom:10px'><input type='button' value='Continue' class='v14b' onclick='if(verFrm())document.form1.submit();'></tr>
My code to open the first webpage, fill out necessary forms, and click the button. Then to click the button on the next page.
Sub FillICEForm()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "website"
ie.Visible = True
While ie.busy
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:02"))
ie.document.ALL("sf").Value = "1"
ie.document.ALL("sd").Value = "100"
ie.document.ALL("cd").Value = "100" 'sd/sf
ie.document.ALL("ci").Value = "100"
ie.document.ALL("r").Value = "100"
ie.document.ALL("st").Value = "2" 'FROM SHEET
'Submit first form
Set the_input_elements = ie.document.getElementsByTagName("input")
For Each input_element In the_input_elements
If input_element.getattribute("class") = "v14b" Then
input_element.Click
Exit For
End If
Next input_element
'Second page
Set the_input_elements = ie.document.getElementsByTagName("input")
For Each input_element In the_input_elements
If input_element.getattribute("value") = "Continue" Then
input_element.Click
Exit For
End If
Next input_element
End Sub