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:
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:
Step3: Drag and Drop Invoke VBA activity from the activities panel to the designer panel as shown below:
The required parameters for Invoke VBA activity are shown below:
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:
What is the color for color index 3?
The below are the list of colors and their color indexes:
Based on these color indexes we can determine the color of the text present in that cell.