VBA IE automation checkbox and submit issues

b.hill2387

New Member
Joined
Mar 28, 2012
Messages
38
The code below works for selecting the checkbox when I am already logged in (in this scenario the log in screen never shows up when a new ie is created), but when I am not logged in the code works for logging me in, but then will not select the checkbox once logged in. In both scenarios I am having trouble clicking submit after selecting the checkbox. Can anyone help me fix either of these two issues? Thank you in advance.
Note: The submit button only becomes available to click after a checkbox is selected.

HTML:
Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Sub Login_2_Website()

Dim oHTML_Element As IHTMLElement
Dim sURL As String

On Error GoTo Err_Clear
sURL = "**************"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True

Do
Loop Until oBrowser.readyState = READYSTATE_COMPLETE

Set HTMLDoc = oBrowser.document

HTMLDoc.all.loginEmail.Value = "*********"
HTMLDoc.all.loginPassword.Value = "******"

For Each oHTML_Element In HTMLDoc.getElementsByTagName("button")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
Next

Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If

HTMLDoc.all("selected_10").Click

For Each oHTML_Element In HTMLDoc.getElementsByTagName("button")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
Next

If Err <> 0 Then
Err.Clear
Resume Next
End If

End sub

I've copied the source code below for the checkbox and the submit button.

Checkbox:
HTML:
<td class="select"><input id="selected_10" name="selected_10" type="checkbox"></td>

Submit button:
HTML:
<div class="buttonBar">
<button class="btn-continue orange" name="continue" type="submit" value="continue">Continue</button>
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top