lundi 10 septembre 2018

Excel VBA - click on a checkbox that only has a label and no name

Sorry in advance if this question has already been asked. I'm extremely new to visual basic for excel and I'm completely stumped on how to program this.

I'm trying to write a program to automate a process at work and one of the tasks is to click on a checkbox located on a website.

This is the only code I can find that is related to this specific checkbox:

On this website, when you first load it, there are drop downs that are closed. You have to open them to click this box. I'm not sure if this is partially why I can't get this work.

This is what I have written to do this specific portion of the task.

Dim Login As MSHTML.HTMLDocument
Set Login = IE.document

  • there is some other stuff in here that's already completed, like logging on automatically. at this point it has also already navigated to the page

    Dim layer As MSHTML.IHTMLElement Dim layers As MSHTML.IHTMLElementCollection

    Set layers = Login.getElementsByTagName("chbx")

    For Each layer In layers

    If layer.Label = "RiverFlood_MapServer" Then
        layer.Click
    
    

    Else End If

    Next layer

I found this by trial and error through looking up how to do this online. I'm really not sure if this is even close to the best approach so any help would be appreciated.

Thanks




Aucun commentaire:

Enregistrer un commentaire