VBA webpage automation: click radio button in next TD with reference to previous TD without ID

tanker1

New Member
Joined
Aug 25, 2017
Messages
4
I'm trying to automatically click a radio button on a webpage. Here's the relevant HTML code:

HTML:
RW B
I want to click the radio button in the second TD.

I can't use the element ID because I intend to use the same macro on other webpages of the same type where the ID and value differ but the layout is identical.

On the webpage GUI, this is as simple as clicking the radio button located beside text "RW B".

I've been attempting to get the macro to latch on to the previous TD with innerhtml "RW B" and then click the INPUT item within the next TD tag.

So far, I've tried the following with no success:
Code:
1
For Each ele In objIE.Document.getElementsByTagName("span")
    If ele.innerHTML Like "RW B" Then
         ele.NextSibling.FireEvent ("*******")
    End If
Next
Code:
2
For Each ele In objIE.Document.getElementsByTagName("span")
    If ele.innerHTML Like "RW B" Then
         ele.NextSibling.Children(0).FireEvent ("*******")
    End If
Next
Code:
3
Var element = objIE.Document.querySelector("input[*******^='SetAccessLevel('B','RW'']")
Code:
4
For Each ele In objIE.Document.getElementsByTagName("td").
    If ele.innerHTML Like "RW B" Then
         ele.NextSibling(0).Firevent ("*******")
     End If
Next
Code:
5
Set objInputs = objIE.Document.getElementsByTagName("input")
For Each ele In objInputs
If Left(ele.*******, 23) = "SetAccessLevel('B','RW'" Then
ele.Focus
ele.Click
End If
Next
Here's more HTML code from the page all the way up to the original div:
HTML:
Group Name
Access Rights

Owners


Group RW B
RW B
</tr></tbody></div>
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
For some reason the HTML code didn't come through properly so here it is again. I've replaced <> brackets with {}:

Relevant HTML code:

HTML:
{TD width="25%"}{SPAN}RW B{/SPAN}{/TD}

{TD width="15%"}{INPUT *******="SetAccessLevel('B','RW');" id=Ctrl_59296626_ctl95 type=radio value=ctl95 name=Ctrl_59296626$GroupAccess}{/TD}

More HTML code from the page all the way up to the original div:
HTML:
{DIV style="BORDER-TOP-STYLE: ridge; BORDER-BOTTOM-STYLE: ridge; BORDER-RIGHT-STYLE: ridge; BORDER-LEFT-STYLE: ridge"}{TABLE width="98%"}
{TBODY}
{TR}
{TD width="25%"}{SPAN style="FONT-WEIGHT: bold"}Group Name{/SPAN}{/TD}
{TD width="25%"}{SPAN style="FONT-WEIGHT: bold; align: center"}Access Rights{/SPAN}{/TD}
{TD width="15%"}{SPAN style="align: center"}{/SPAN}{/TD}
{TD width="25%"}{SPAN style="FONT-WEIGHT: bold"}Owners{/SPAN}{/TD}
{TD width="15%"}{SPAN style="align: center"}{/SPAN}{/TD}{/TR}
{TR}
{TD width="25%"}{SPAN}Group RW B{/SPAN}{/TD}
{TD width="25%"}{SPAN}RW B{/SPAN}{/TD}
{TD width="15%"}{INPUT *******="SetAccessLevel('B', 'RW');" id=Ctrl_59296626_ctl95 type=radio value=ctl95 name=Ctrl_59296626$GroupAccess}{/TD}
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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