SOLVED - Get Cell Color Function

excel
activities

#1

Hi

Can someone possibly assist me with this one, I’ve searched the forums and Googled but can’t find a relevant answer.

I wish to use the Get Cell Color function in order to see if a cell is grey.

I then want to feed this into a flow decision, so that if the cell is grey it will follow true and follow one process or if false will follow a different process.

I use the Excel Application Scope to define the spreadsheet, and then the Get cell colour function within this to retrieve the colour. However I’m not sure how to proceed from this point, or how it will feed into the flow decision.

22

Any help, greatly appreciated, thanks!


Formatting in Excel
#2

So I’m not sure how you can access the cell color directly within UiPath without vba or vbs.
However, if there is a reason why it’s Grey then you really don’t need to if you can look at the condition as to why it’s grey in the first place.

As a workaround you can use key combinations to track down the color using the Menu.
Like,
TypeInto
"[k(alt)]hhm[k(right)]"

That key combination goes to the Color of the selected cell.


#3

Hi Searl!

Please try the following:

First, be sure you have created a variable to hold the color you’re finding in your “Get Cell Color” activity. This should be a “System.Drawing.Color” variable type:

Next, be sure that this variable is assigned as the Color output from your “Get Cell Color” activity:

Finally, set the “Condition” of your flow decision as follows:

Essentially what this is doing is taking the Color variable you created (called “colorFound” in my example), converting this to a string (using “.ToString”), and then checking to see if this is equal to “Color [Gray]”. The flow decision uses the results of this comparison to determine if it should then continue down the “True” or “False” path.

One thing to note is that the specific color definition you are looking for in your situation (i.e. “Color [Gray]” in my example) may be different than mine. (In other words, you may be looking for a “Color [Dark Gray]”, or something like that.) To double-check the exact string-translation of the color you are looking for, you can try temporarily inserting a “Message Box” or “Write Line” activity into your code following your “Get Cell Color” activity like so:
image

Hope this helps!

Cheers,
Riley


#4

fyi…you can use colorFound.Name property


#5

Thank you so much guys!

That has worked perfectly for what I wanted. I had to use the temporary message box to get the exact color reference, as you stated, which came to “Color [A=255, R=191, G=191, B=191]”.

Now my flow works as intended :slight_smile:


#6

Hello Searl,

Can you please share your sample workflow. Because I want my flow to detect color of a box and if color match with required color then it should return the text or name of the box.

For example:
image

Like if color is red then flow should its name ‘GLD_APU2’.

Thanks in advance :slight_smile: