Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Figuring out what the Shape Indexes are.
All,
I am trying to create macros for some ellipse objects on my sheet so that when a user clicks on it it will turn either white or red depending on what color it is already. I can't figure out how to determine what the index is for the object so I can reference it in the Fill command. Here is the code I have so far for one of the ellipses. Sub Oval78_Click() If Worksheets(1).Shapes(1).Fill.ForeColor.RGB = RGB(255, 255, 255) Then Worksheets(1).Shapes(1).Fill.Background.RGB = RGB(255, 0, 0) Else Worksheets(1).Shapes(1).Fill.ForeColor.RGB = RGB(255, 0, 255) End If End Sub Now I assumed that the index number was 78 as in the objects name"Oval78", but that doesn't seem to change the color. I dont get any errors nor do I see anything actually change colors. I am using index number 1 because thats the only thing that doesnt give me a error. Can any one provide me with some tips? TIA Jeff Reed |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Figuring out what the Shape Indexes are.
Jeff,
If I follow what you are trying to do, you could assign all your shapes (ellipse objects?) to a single macro, something like this: Sub ChangeColor() Dim sh As Shape Dim C As Long 'MsgBox Application.Caller Set sh = ActiveSheet.Shapes(Application.Caller) With sh.Fill C = .ForeColor Select Case C Case RGB(255, 255, 255): C = RGB(255, 0, 0) Case RGB(255, 0, 0): C = RGB(255, 0, 255) Case Else: C = RGB(255, 255, 255) End Select .ForeColor.RGB = C End With End Sub This could be adapted to cater for different color combos depending on the calling shape. Regards, Sandy -----Original Message----- All, I am trying to create macros for some ellipse objects on my sheet so that when a user clicks on it it will turn either white or red depending on what color it is already. I can't figure out how to determine what the index is for the object so I can reference it in the Fill command. Here is the code I have so far for one of the ellipses. Sub Oval78_Click() If Worksheets(1).Shapes(1).Fill.ForeColor.RGB = RGB (255, 255, 255) Then Worksheets(1).Shapes(1).Fill.Background.RGB = RGB (255, 0, 0) Else Worksheets(1).Shapes(1).Fill.ForeColor.RGB = RGB (255, 0, 255) End If End Sub Now I assumed that the index number was 78 as in the objects name"Oval78", but that doesn't seem to change the color. I dont get any errors nor do I see anything actually change colors. I am using index number 1 because thats the only thing that doesnt give me a error. Can any one provide me with some tips? TIA Jeff Reed . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
figuring tax | New Users to Excel | |||
Vlookup using concatenated column indexes | Excel Worksheet Functions | |||
Figuring Age | Excel Worksheet Functions | |||
my curser changed from arrow shape to a cross shape???? | New Users to Excel | |||
Figuring hours | Excel Worksheet Functions |