cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VB Script how to find color of drawingitem

SVanSchoonlandt
Honored Contributor

Hi all,

 

I'm working on a script for a diagram and I'm looking for the code to find out which color the user applied to a rectangle drawingItem. I have been trying most of the properties of the drawingItem but none seems to give me the color of the item, with Brush.Color I see it's set to -1 when a color is used but I need to have the RGB values or any other indication that I can use to identify the color.

 

Any ideas?

 

thanks

1 Reply

SVanSchoonlandt
Honored Contributor

I found the trick around this one. The Brush.Color is returning a negative value. You need to add 16777216 to this value and from that result take the hexadecimal to find the right color code. My code

 

Function hexColorCode(inDecimalColorCode As Long) As String
Dim lColor As Long
If inDecimalColorCode = 0 Then
hexColorCode = "000000"
Else
lColor = 16777216 + inDecimalColorCode
hexColorCode = (String(6 - Len(Hex(lColor)), "0")) & Hex(lColor)
End If
End Function