Selectors again, since I didn't get any answers on the other one let's try this

I am trying to close excel after saving the file. I am using the click activity and to attempt to push the X on the close, upper right. I have used the “indicate on screen” twice the same way and got two different selectors and neither of them work.

<wnd app='excel.exe' cls='XLMAIN' title='cryptocurrencys.xlsm - Excel' />
<wnd cls='NetUIHWND' idx='1' />
<ctrl idx='3' name='Close' role='push button' />


<wnd app='excel.exe' cls='XLMAIN' title='cryptocurrencys.xlsm - Excel' />
<wnd cls='NetUIHWND' idx='2' />
<ctrl name='Ribbon' role='property page' />
<ctrl idx='1' name='Close' role='push button' />

as I said in my other Selectors Topic, “Understanding Selectors in Detail” I have not, so far, found anything that documents what the different parts of a selector mean. I have some indications of course but when one doesn’t work and throws and exception there is no help in figuring out which part of the selector is not recognized.
I am finding selectors flaky and fragile. They work for awhile then simply quit and throw exceptions.

Anyway can someone give me a clue why the “indicate on screen” gave me two different selectors and what is wrong with either of them so I can get excel to close reliably? Or another way would be fine. I tried a simple macro with application.quit but that threw and exception as well. ARGGGHHHH…I’m posting another topic on that one

Hi @billpennock,

Instead of clicking X button to close the Excel File, you can use Close Application activity to close the excel file.


I Hope this one will work

<wnd app='excel.exe' cls='XLMAIN' title='cryptocurrencys.xlsm - Excel' />
<wnd cls='NetUIHWND'  />
<ctrl name='Close' role='push button' />


Good grief I forgot all about that one. Duh. Thanks.
can you give me any guidance on what the different parts of a selector really mean or where to find that information, since I’m sure it would be extensive?

yours, for instance, just took the indexes off. What made you think of that?

Hi @billpennock,

For example take the above selector

compared to above two selector idx values is differing so i removed that one. in excel you have only one close button so i just removed the idx vaues. without idx values also the selectors will work.

If suppose values is dynamically changing means you can use '*'

Sorry i hope my English is bad try to understand :wink:


English not a problem. it’s understandable. So that was a good catch on the differences between them. It’s interesting that, like you say, there is only one close button so where does the idx=3 come from. I did try yours and that didn’t work either. I’ve attached the workflow even though close application was the right answer. I’m just looking for anything I can on how to understand selectors because they seem to be very flaky and I hope it’s my understanding of them more than the selectors themselves. The test references a spreadsheet but the only thing needed in the spreadsheet is the macro “MaximizeActiveWindow” which contains “ActiveWindow.WindowState = xlMaximized” to get to full screen because I found if I didn’t do that then excel might open with all sorts of wierd window sizes and some of them would make the activities not work. “main has thrown an exception” “Bill has thrown a fit” Joking of course. testinghotkeyselectors.xaml (15.9 KB)

HI @billpennock,

yes i agree close application is the correct one.

can you just try this selector.

<wnd app='excel.exe' cls='XLMAIN' title='*' />
<wnd cls='MsoCommandBar' title='Ribbon' />
<wnd cls='MsoWorkPane' title='Ribbon' />
<wnd aaname='Ribbon' cls='NetUIHWND' />
<ctrl name='Ribbon' role='property page' />
<ctrl idx='1' name='Close' role='push button' /> 


Tried it, still exception error. Maybe that’s why UIPATH came up with the close application activity

Do you have more than 1 Excel file open? That could explain idxs and their values can differ depending on what is considered “on top”.
For various nodes in generated selectors, Uipath generates the least information needed to traverse ui tree and find the element at the moment of generating selector. So when generating it might be enough, but if you alter application state (f.e. Display different menu part on ribbon) it might not be enough during execution.

don’t have other excel open. I’ve already noticed that about how rigid you have to keep the app state for it all to work.

Hi ,

Can we have selectors, based on ctrl id .

Will they differ when moved from lower environment to higher environment?