PDA

View Full Version : Solved: Using named shapes



clvestin
05-30-2006, 12:13 AM
I'm using graphics on a worksheet. When a user ckicks the graphic, the worksheet selection change refers them to a new sheet. I would like to name the graphics and then use that name in vba code.
For example:

Sub Worksheet_SelectionChange(ByVal Target As Range)
'Worksheets("Ctrl Bldg").Shapes("io2").Name = "rectangle 4"
Worksheets("Ctrl Bldg").Shapes("i_o_2").OnAction = "select_io2"
Worksheets("Ctrl Bldg").Shapes("rectangle 45").OnAction = "select_io3"
Worksheets("Ctrl Bldg").Shapes("rectangle 46").OnAction = "Select_IO3A"
Worksheets("Ctrl Bldg").Shapes("rectangle 48").OnAction = "Select_lp1"
Worksheets("Ctrl Bldg").Shapes("rectangle 49").OnAction = "Select_pp4"
Worksheets("Ctrl Bldg").Shapes("rectangle 50").OnAction = "Select_pp5"
Worksheets("Ctrl Bldg").Shapes("rectangle 51").OnAction = "Select_pp6"
Worksheets("Ctrl Bldg").Shapes("rectangle 16").OnAction = "Select_Term1"
End Sub


In the above code the shape I'm refering to as i_o_2 has been named in Excel proper(I think). I selected the shape, insert name,define--and the name shows to refer to ="Rectangle 67". However, when the name is used in the code, no work.
Any thoughts would be appreciated.

Bob Phillips
05-30-2006, 02:09 AM
Don't set the name in that way, select the shape, and then type the new name directly into the Names box, to the left of the formula bar.

MountainVogu
05-30-2006, 02:13 AM
Clvestin,

You are creating a named range not naming the object.

To name the object in the "Front end" ensure the formula toolbar is active (View, Formula Bar)
Select the Object, its name will appear in the Name Box
Then select the name box and type the desired name of your object.

clvestin
05-30-2006, 02:24 AM
ok-I'm thick. Thx for the quick responses.