Dynamic Excel radio button selection

Hi all, apologies if this has been answered already, but I’ve been unable to locate the answer. How can you click on a radio button in Excel based on its text?

I have a series of Excel files that all contain radio buttons. I am working on a process where I open each Excel file, select a particular radio button. What it does beyond that is irrelevant to this question. When I indicate my radio button in Excel, it creates a selector based on idx value, but I cannot trust that value as the values may differ between excel files. I would like to create a selector based on the text of the radio button, but cannot seem to target that text without using image selector or computer vision (both of which have been inconsistent).

I’ve tried using UI Explorer, but do not see the text of the radio button in the Property Explorer, there is no child of this Rectangle, and I cannot select that text as an anchor.

What do I need to do to target a radio button in Excel by its associated label text?

Hi @Jeffrey_Clark

Please look into this thread , hope it helps

Thanks @Kanak_Lata_Singh. I had seen this post, but they are targeting Chrome and using webctrl. I’m targeting excel.exe (desktop app). Also, that solution relies on aaname and innerText being the value of the label text. In my situation, aaname is always the name of my Excel file (test.xlsx) for every option, and the Fuzzy selector only matches if I use text of ‘Rectangle’.

give a try by switching with F4 the UiFrameworks and check for alternate selector offerings

UI Automation gives me the same selector as Default. Active Accessibility only seems to target the entire data panel (all rows/columns). It won’t allow me to target the controls within that panel. When I try to click on any of the controls, it just gives the following selector:

<wnd app='excel.exe' cls='XLMAIN' title='test.xlsx - Excel' />
<ctrl name='test.xlsx' role='client' />

I’ll attempt to upload my test spreadsheet if anyone wants to try for themselves.
test.xlsx (174.3 KB)

Try CV, it should be able to identify the individual radio buttons and their labels.

I had tried CV, and it was almost a good solution. I was able to pass a variable to target the radio buttons by text in a single Click activity. The problem with CV was that in my real-world scenario, the radio buttons are regions, and CV would sometimes confuse “Northeast” and “Southeast”. They are only different by 2 letters, but I was disappointed that it would sometimes confuse the 2.

I have also tried Image, which has worked the best so far, but breaks if the screen resolution or background color changes. It also requires a Click activity per option that I want to target.

I was hoping that there was something I was missing with strict or fuzzy selectors. Seems odd that the label of a radio button in excel would not be something that can be targeted.

I notice in your selector screenshot it shows the name as “Rectangle.” Are there properties of the radio buttons that you can edit and change the name of each one?

after a quci check we would state that the radiobuttons are poorly offered for selectors. So we can check for work arounds

  • VBA / Macro

When you have a part control on the excel and can do some modifications we can also use the cells for helping us by marking the value and let click the cell with the specific marker. This can lead to also click on the radio button

UPD1 - Visuals
grafik
grafik

where we can use the index / cell positions and get it calculated by reading the B col cell values

Unfortunately these are spreadsheets are not under my control and are historical (weekly data from last year). Requesting changes to them (properties or macros) is not an option. Also note that the radio buttons are not in any of the cells. I have resized the rows and added cell borders to illustrate.

image3
.

OK, as we can send VBA against the Excel or Script with interop Code, we do not have to modify the excel eg adding a macro.

Maybe you can present more Details of the role of the Radiobuttons and what will it do, once clicked. Thanks

I’m going to mark this as the solution because you got me thinking differently about the problem. Turns out if I right-click on the control, select ‘Format Control’, and select the ‘Control’ tab, it is linked to a cell in a hidden sheet. That cell seems to control what data is displayed elsewhere on the sheet that contains the radio buttons. I can probably find a way to modify this cell in the hidden sheet directly and completely bypass clicking the radio buttons.

I do think it’s unfortunate that UiPath can only target these Form Controls by their index (which changes if you start editing these controls), and seems to have no visibility to their text. These controls also have an ‘Alt Text’ property, which is independent from the label shown on the control, but neither value is exposed using UI Explorer.

BTW, this is a standard feature of Excel. Just customize the ribbon to expose the Developer tab, and you can insert Form Controls onto a sheet. They all work the same way, and UI Explorer can’t target the text of any of them.

And thank you @ppr & @postwick for taking the time to help.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.