+ Reply to Thread
Results 1 to 5 of 5

Determining what object was clicked.

  1. #1
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Determining what object was clicked.

    I assign the same macro to all my ToggleButtons, and use Application.Caller to determine which button was clicked.
    Please Login or Register  to view this content.
    I also do the same thing for CheckBoxes, but using this code
    Please Login or Register  to view this content.
    I would like to do the same thing for OptionButtons, but I can't figure out what to put here:
    Please Login or Register  to view this content.
    "s" has the name of the OptionButon in it, but I can't get it into an object.
    "OptionButtons(s)" doesn't work and neither does "Shapes(s)".
    How can I get the OptionButton object?

    I know that I could probably cycle through all the shapes on the worksheet looking for the one with that name, but I would rather go directly.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,322

    Re: Determining what object was clicked.

    OptionButtons is the correct collection (assuming you used Forms controls)
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Determining what object was clicked.

    romperstomper;
    I just discovered my problem. I had the option buttons grouped, so even though I had the individual button name, there is no ActiveSheet.OptionButtons(<button name>), it's inside a group collection.

    Do you know how I can get the option button into an object when it's grouped?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,322

    Re: Determining what object was clicked.

    In 2007 it should work whether grouped or not, I think. For earlier versions I think you will need to loop through the shapes, check the type (if it's 6, it's a group) and then iterate the groupitems and check the name.

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Determining what object was clicked.

    It's not working in my version of 2007.

    I'm now developing code to cycle through all the shapes looking for groups to cycle through. Glad to know I'm on the right track.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1