wittman
wittman

Reputation: 305

Check the checkbox on a web page from Outlook

I am having trouble with the checking of a check box from a web page. I have tried:

    Do
         ' Wait till the Browser is loaded
    Loop Until oBrowser.ReadyState = READYSTATE_COMPLETE

     Dim HTMLDoc As HTMLDocument
    Set HTMLDoc = oBrowser.Document


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


    Application.Wait (Now + TimeValue("0:00:05"))
    oBrowser.Visible = True

    'oBrowser.Document.forms(0).all("tdFilter").Item(0).Click
    oBrowser.Document.forms(0).all("tdFilter").Click
    'IE.Document.forms(0).all("tdFilter").CheckBox = True

     ' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
    If Err <> 0 Then
        Err.Clear
        Resume Next
    End If
End Sub

end this is the source code:

enter image description here

Upvotes: 0

Views: 103

Answers (1)

J. Farro
J. Farro

Reputation: 71

Not sure I understand the reason for the loop:

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

Also, "orderById is an id, so should you not just reference it as:

HTMLDoc.getElementById("orderById")

Similarly you could set the checkbox with:

HTMLDoc.getElementById("tdFilter").Checked = True

If it is not working, inspect your elements, make sure you have the right names, make sure you do not have duplicate ids and also check how your events are triggering.

Upvotes: 1

Related Questions