Announcement

Collapse
No announcement yet.

Checking For Shape Name On Click

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Checking For Shape Name On Click



    I am trying to create a clickable image map. I have one macro that is activated when any shape is clicked, but it executes different conditions depending on which shape is clicked.

    How do I check whether a specific shape is clicked?

    Some of the code I tried:
    Code:
    If ActiveSheet.Shapes("Freeform51") <> null Then
    ...
    Also:
    Code:
    If ActiveSheet.Shapes(Shapes.Name).OnAction = "Freeform51" Then
    Also, is there an easy way to pull the shape names and manually change them?
    Last edited by sleepeeg3; January 31st, 2007, 03:57.

  • #2
    Re: Checking For Shape Name On Click

    Perhaps you could use Application.Caller?

    That will work depending on what type of 'shapes' you have.
    Boo!

    Comment


    • #3
      Re: Checking For Shape Name On Click

      Thanks! It seems like what I need. I can get it to generate a message box with the shape name, but I am having trouble storing it to a variable. I keep getting "object required" errors. What am I doing wrong here:
      Code:
       Dim State As String
       Set State = ActiveSheet.Shapes(Application.Caller).Name '<- errors here
       
       MsgBox "This macro was called by: " & ActiveSheet.Shapes(Application.Caller).Name

      Comment


      • #4
        Re: Checking For Shape Name On Click

        I don't see why you need anything other than Application.Caller if you just want the name.
        Boo!

        Comment


        • #5
          Re: Checking For Shape Name On Click

          Use Set for objects not properties of an object

          State = ActiveSheet.Shapes(Application.Caller).Name 

          Cheers
          Andy

          Comment


          • #6
            Re: Checking For Shape Name On Click

            norie, sorry that example was just for testing. I was also using it to pull the shape names.

            andy, wow that was easy - that did it! Thanks to both of you for helping start my day out right.
            Last edited by sleepeeg3; January 31st, 2007, 23:51.

            Comment


            • #7


              Re: Checking For Shape Name On Click

              I'm trying to do something similar to what's detailed above, however instead of clicking on a Shape I'm using a Group (of shapes). When I use the code above it only returns the name of one of the Shapes in the Group no the Group Name. Does anyone know how to extract the Group Name by clicking on a group of shapes?

              Thanks,

              Froesch

              Comment

              Working...
              X