Consulting

Results 1 to 3 of 3

Thread: Application level click event for shape

  1. #1
    VBAX Contributor
    Joined
    Apr 2014
    Posts
    109
    Location

    Application level click event for shape

    Hello...

    I am working on a code which will use the data in tables to draw various lengths of rectangles on a time-map. In other words, if the bus is being used for 2 days, the rectangle will be 2 days long on the calendar. Since the company may purchase new coaches from time to time, I don't want to pre-determine all the rectangles, but let the code create them. In general that is easy enough. But where I find the difficulty is in clicking on that line to bring up the details contained in the filtered table (driver, bus no, date-time out, date-time in). I will describe the reason for the difficulty below.

    I chose to use an Active-X label for the shape, because it cannot be selected once design mode is off. If I give that shape a name, then I can easily create a click event as follows:
    Private Sub Shape1_Click()
        'stuff about shape
    End Sub
    That works. But it means I have to assign specific shapes for how many possible buses due to purchase, sale, loss, etc. So what I want is to use the code to create shapes as needed, regardless of their names, and to use the data on the sheet to assign length, etc. It could then make a label (bus number) which is used to find other data during the click. The click I need is for shapes in general. You click or double click and the one event is triggered no matter what shape or item on the worksheet is clicked. Then the code could eliminate certain items by
    "If shapes.name = "notthisshape" then exit sub.
    I have found some answers suggesting that I use Application.Caller, but they didn't show how I would assign the trigger.

    That is the idea, but is this at all possible?
    If not, any suggestions of which direction I could go?

    Thanks in advance.
    Gary

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,717
    Location
    Simple example
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Contributor
    Joined
    Apr 2014
    Posts
    109
    Location
    Quote Originally Posted by Paul_Hossler View Post
    Simple example
    Thanks for that, Paul.

    You assign the same Macro to each box created, give each a different name on creation, and use that name to figure out which one is being clicked on.
    I like the possibilities.



    Gary

Posting Permissions

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