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.
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.