lundi 25 juillet 2022

VBA IE check and uncheck the checkbox with same-name and different-values "document of object iwebbrowser2 failed" error

As you can see i tried many different codes but i'm still getting "document of object iwebbrowser2 failed" error and i have no idea why please help

My HTML Code

<tr>
        <td width="4%" align="left" valign="middle"></td> 
        <td width="96%" align="left" valign="middle"><font face="arial" size="1.5">
            <input align="top" type="checkbox" name="R_CustInst" value="51">
<b>BANK2</b></font></td>
    </tr>
<tr>
        <td width="4%" align="left" valign="middle"></td> 
        <td width="96%" align="left" valign="middle"><font face="arial" size="1.5">
            <input align="top" type="checkbox" name="R_CustInst" value="52">
<b>BANK1</b></font></td>
    </tr>

My VBA Code

Sub test()

Set sht = ThisWorkbook.Sheets("Sheet1")
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://"

Do
If IE.ReadyState <> 4 Then
IE.Visible = True
Exit Do
Else
DoEvents
End If
Loop

'Dim chBox As Object
'
'    Set chBox = IE.document.getElementsByName("R_CustInst")
'
'    chBox(52).Checked = True
IE.document.querySelector("[name=R_CustInst][value='52']").Click

'IE.document.getElementsByAll("[name=R_CustInst][value=52]").FireEvent
'<input align="top" type="checkbox" name="R_CustInst" value="52">
'IE.document.all("R_CustInst")(52).Checked = True
'IE.document.getElementsByTagName("BANK1").Click
'IE.document.getElementsByValue("52")
'IE.document.getElementByAttribute("Type").Click
'IE.document.getElementById("Type").Click

Set IE = Nothing

End Sub

i'm new to this and i'm a mess been at it long and i give up Please help PLEASE!




Aucun commentaire:

Enregistrer un commentaire