Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Many thanks. I'll continue my exploration of colors. James
Peter T wrote: Since my drawing object may be set with a scheme color OR with RGB colors, Just to clarify there will always be an RGB colour but not necessarily a returnable scheme-color, which confirms a custom colour has been applied NOT from the palette. The previous palette colorindex also exists at the drawingobject level, though not displayed if a 'fixed-RGB' format has been applied. Regards, Peter T "Zone" wrote in message ups.com... Thanks, Peter. Since my drawing object may be set with a scheme color OR with RGB colors, my next thought was how to detect either. If I understand your reply correctly, if I try to display the scheme color for an object set with RGB, I'll get an error, so I could use that error to bail from the scheme color and go to detecting RGB as Michael explained. Regards, James Peter T wrote: Just to add, colour formats in shapes, such as fill, border, line (but not font) can have a 'fixed-RGB' colour not linked to the palette. With a 'fixed-rgb' colour testing for its Schemecolor will throw an error, which indeed is how to test for such a format. Sub test() Dim ln As Line, cx As Long, clr As Long For Each ln In ActiveSheet.Lines With ln.ShapeRange.Line.ForeColor cx = -1 On Error Resume Next cx = .SchemeColor 'error if 'fixed-RGB' colour On Error GoTo 0 clr = .RGB End With Debug.Print ln.Name, cx, clr Next End Sub Subtract 7 from the schemecolor to return the equivalent colorindex. But if cx = 64 the equivalent colorindex is automatic (system black for forecolor), or -1 in the above example indicates a fixed-rgb colour. There is also a Backcolor property for the pattern colour (or 2nd effect colour in fill). Regards, Peter T wrote in message oups.com... I can extract the pallette value using the code below.. If there is a requirement to reuse this color elsewhere then you won't need RGB because all other objects will work with the same pallette..however if you still need RGB for another purpose let me know. ---------------------------- For Each Shape In ActiveSheet.Shapes msg = msg & vbCrLf & Shape.Name & " " & Shape.Line.ForeColor.SchemeColor Next MsgBox (msg) ---------------------------- Zone wrote: The Line is a drawing object. Thanks, James wrote: By line I can't determine if you have a drawing object or cells which have their pattern set to the pallette.. If it is the cells color then the VBA code to return it's pallette value is: ----------------------------- With ActiveCell.Interior .ColorIndex = NumColor End With msgbox (NumColor) ----------------------------- I am not sure how to extract RGB values from the pallettes own settings but if you become more clear on the requirement I am sure there is some solution we can locate. HTH, Will Zone wrote: I have a line on a worksheet and its color is set with RGB settings. I want to select the line and run a macro that will show me the RGB settings. TIA, James |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Zero Value Settings | Excel Discussion (Misc queries) | |||
TAB Settings in Excel | Excel Discussion (Misc queries) | |||
Settings | Excel Discussion (Misc queries) | |||
settings | Excel Worksheet Functions | |||
Add to Settings.txt | Excel Programming |