Re: Get RGB settings

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



wooooo-hooooo!
Michael, worked like a charm. I've never implemented a user-defined
type before, but it certainly did the trick. I want to get the back
color as well, so I just added that to your code, as below. Any
problem with this? Since the selected object might be a rectangle,
circle or freeform instead of a line, I want to be able to get the fill
RGB as well, so that will be my next effort. I found with a rectangle,
I had to select the actual outline to get the line RGB settings for the
line, which evidently means I'll need to select the fill to get the RGB
settings for the fill. Many thanks. May be posting back.
James

Private Type RGB_Wrapper
Red As Byte
Green As Byte
Blue As Byte
Alpha As Byte
End Type


Private Type LNG_Wrapper
Value As Long
End Type

Sub RGB_Settings()
Dim Color As LNG_Wrapper, Colors As RGB_Wrapper
Dim ColorB As LNG_Wrapper, ColorsB As RGB_Wrapper
Color.Value = Selection.ShapeRange.Line.ForeColor
LSet Colors = Color
ColorB.Value = Selection.ShapeRange.Line.BackColor
LSet ColorsB = ColorB
MsgBox "Line Fore Color" & vbLf & "Red: " & Colors.Red & " " _
& "Green: " & Colors.Green & " " _
& "Blue: " & Colors.Blue & vbLf & vbLf _
& "Line Pattern: " & Selection.ShapeRange.Line.Pattern & vbLf & vbLf
_
& "Line Back Color" & vbLf _
& "Red: " & ColorsB.Red & " " _
& "Green: " & ColorsB.Green & " " _
& "Blue: " & ColorsB.Blue
End Sub

Michel Pierron wrote:
Hi Zone,
With something like that (by assigning this macro to your line):

Private Type RGB_Wrapper
Red As Byte
Green As Byte
Blue As Byte
Alpha As Byte
End Type

Private Type LNG_Wrapper
Value As Long
End Type

Sub RGB_Settings()
Dim Color As LNG_Wrapper, Colors As RGB_Wrapper
Color.Value = Active***.Shapes("Line 1").Line.ForeColor
LSet Colors = Color
MsgBox "R: " & Colors.Red & vbLf _
& "G: " & Colors.Green & vbLf _
& "B: " & Colors.Blue
End Sub


"Zone" <jkend69315@xxxxxxx> a écrit dans le message de news:
1155043258.021031.53150@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a line on a work*** 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


.


Quantcast