Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Location Clicked (2000 sp3)

    I can't seem to find an answer to this question, maybe I'm not searching on the right words.
    I have a workbook in which the same image appears in many places and each one is assigned to the same macro. Is there any way, in the macro, to determine which image was clicked? Its row would be sufficient. I solved this in another workbook by assigning unique macros which then call the common macro, but this workbook has so many I thought it would be worth asking is anyone knew a better way.
    I sure would appreciate any help you can give.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Location Clicked (2000 sp3)

    Application.Caller will tell you the name of the image clicked by the user. To get information about the image, you can use ActiveSheet.Shapes(Application.Caller). For example, ActiveSheet.Shapes(Application.Caller).Top and ActiveSheet.Shapes(Application.Caller).Left provide the distance (in points) of the image from the top/left edge of the worksheet.

  3. #3
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Location Clicked (2000 sp3)

    Wow! I can't tell you how much time I spent trying to figure something out to do this! Thanks so much for pointing me in the right direction, again! This is great.

  4. #4
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Location Clicked (2000 sp3)

    Thanks again Hans.
    This works great when the names of the images are unique but the author of this workbook must have copied and pasted some of the images and they have the same name. This seems to cause confusion since all of the images with the same name get the same values returned, namely the properties for the first image with that name. Before I search for all the images and change the names of the duplicates, is there any way around this? (I didn't know it was possible to create multiple shapes with the same name!)
    Thanks

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Location Clicked (2000 sp3)

    Try running the following macro to rename the shapes:

    Sub RenameShapes()
    Dim i As Long
    For i = 1 To ActiveSheet.Shapes.Count
    ActiveSheet.Shapes(i).Name = "MyShape" & i
    Next i
    End Sub

    You can replace "MyShape" with whatever you prefer, as long as you don't create a conflict with existing names.

  6. #6
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Location Clicked (2000 sp3)

    Cool! That works for me.
    Thanks again

Posting Permissions

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