Consulting

Results 1 to 4 of 4

Thread: Solved: Using named shapes

  1. #1
    VBAX Regular
    Joined
    Jul 2005
    Posts
    74
    Location

    Solved: Using named shapes

    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:
    [VBA]
    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
    [/VBA]

    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.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.

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

  4. #4
    VBAX Regular
    Joined
    Jul 2005
    Posts
    74
    Location
    ok-I'm thick. Thx for the quick responses.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •