Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
figuring tax jesseok New Users to Excel 2 October 22nd 08 02:11 PM
Vlookup using concatenated column indexes Matt Excel Worksheet Functions 7 June 9th 08 02:07 AM
Figuring Age Sue Excel Worksheet Functions 2 March 18th 08 05:51 PM
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Figuring hours scott45 Excel Worksheet Functions 6 August 29th 05 09:54 PM


All times are GMT +1. The time now is 04:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"