Reading excel tab color

Hi all,

Is there a way to read an excel tab color in UiPath? I would like to extract information from a workbook with several tabs, but only for the ones which have a certain color.

Alternatively, it would also be fine to exclude tabs with red color, for example.

Thank you!

1 Like

You can use Get Cell Color activity

Hi @Rahul_Pasupuleti,

Thanks for your reply. I mean reading the color of the tab, where you see the tab name. Is it possible with get cell color? If so, can you give an example or explain please?



Yes, this is possible. Use VBA to get the color. The output is in RGB.

Sub Tab_Color()
ans = ActiveSheet.Tab.Color
MsgBox ans
End Sub

Please let me know if that didn’t work.

1 Like

Hi @bradsterling

Thank you for the answer! I can run the code and get the text box. In my project, I have several excel workbooks with many tabs each. For all of these workbooks, some of the tabs are red, others not. What I would like to do is for each of the tabs in each of the workbooks, extract certain information if the tab color is not red. Most of my workflow is built already, its just that at this moment I can not identify which tabs are red and which are not, so in the end im extracting the info from every tab.

Therefore, what would be your recommendation to overcome this?

Thanks for your time!


Ok, so it sounds like you have the logic down for your process. I’m guessing you have implemented some sort of loop to check if a tab is red or not. Then using an If statement based on if the RGB is red, you continue.

You can modify the VBA to best fit your needs. If excel is open, it can read the message box using get text. Are you asking what alternative ways there are to determine the color besides a text box?

How does that work? I don’t know anything about VBA and using it and I need to do the same kind of thing. I want to use this to get a list of sheets with a certain color so I can get the data on those sheets to process.

@alicat0818 Excel Sheet (6.7 KB)

There are probably better methods but this outputs the color of the tab. This uses the ClosedXML namespace so make sure its imported on your project. You can find more information at:

I can’t see any information on github related to this. How does it work? Do I just put the name of the file I’m trying to read in the filename variable?

Thanks a bunch. After I got over feeling like not having a clue I figured out how it worked and it’s perfect for what I need to do.

Excellent! Please mark as solution in hopes others find useful.

Ran into a snag. I imported ClosedXML.Excel like you said, but it gave me this when I tried to run it in the middle of my process.