How to find the text color in excel cell using UiPath

While working on excel automation, sometimes we might need to find the text color in the excel cell.

There are cases while automating a business process sometimes we might need to take the next step based on the color of that text present in one column.

In this article, let’s see how to find the text color in an excel cell using VBA in UiPath.

Let’s get into the practical implementation of this task:

Step1: The input for this example is shown below:

input data

If you observe clearly we can see A2 cell color is different from others.

Step2: Drag and Drop Excel application scope activity from the activities panel to the designer panel as shown below:

excel application scope

Step3: Drag and Drop Invoke VBA activity from the activities panel to the designer panel as shown below:

find the text color in excel

The required parameters for Invoke VBA activity are shown below:

find the text color in excel

Here:

  • CodeFilePath – The filepath where code is stored.
  • EntryMethodName – Provide the function name which is used in the code.
  • EntryMethodParameters – Provide the input parameters for the VBA code if any.
  • OutputValue – Gives the color index of the text present in excel cell as output.

The below is the VBA code that is used for this example:

Function GetFontnumber(param1)
GetFontnumber = Range(param1).Font.ColorIndex
End Function

In this example param1 is A2

Step4: The output for the above code is shown below:

vba color index

What is the color for color index 3?

The below are the list of colors and their color indexes:

VBA Color codes

Based on these color indexes we can determine the color of the text present in that cell.

Happy Learning!

Like this post then let your friends know about this-:

Leave a Reply

Your email address will not be published. Required fields are marked *