List of Cell Colors

I am currently working with a List that is full of color string names that can be used in the set range color activity, however I cannot use the values ​​in the list since being string I cannot use them in the activity instruction what I’m trying to do is something like Color.ColorList(0) can someone tell me how I can make this work considering that my list of colors are string values?

Hi @WSay

Try getting the variable type of the excel colours, and creating a list of them that way, you could cast your current string if that’s not possible.

Kind Regards

For a start have a look here getting all names from the KnownColor Enum:


System.Enum.GetNames(GetType(System.Drawing.KnownColor))

And getting back the enum value for a string we can do:
grafik

 DirectCast(KnownColor.Parse(getType(KnownColor), "Purple"),KnownColor)
 Purple
 DirectCast(KnownColor.Parse(getType(KnownColor), "Purple"),KnownColor).GetType
 [System.Drawing.KnownColor]

As an example

2 Likes

This helped me a lot, thank you very much!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.