+ Reply to Thread
Results 1 to 7 of 7

Click event of dynamically created label

  1. #1
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Click event of dynamically created label

    Hi

    I am adding label to my excel sheet using OLEObjects.Add as seen below.
    This works fine.

    Please Login or Register  to view this content.

    How do I write the code that will fire when user clicks these labels?
    tia
    Ajay
    Last edited by ajaykgarg; 07-03-2010 at 10:10 AM.

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

    Re: Click event of dynamically created label

    I would recommend you use a Textbox drawing object rather than an ActiveX control on the sheet. You can then simply assign the OnAction property as you attempted to do in that code.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Click event of dynamically created label

    Thanks, for the prompt reply romperroster.

    However, I get the same error woth text box too.

    Pl. see attached file. (clicking on the command button will create text box and attempt to assign it an OnAction event)

    Can you tell me what I am doing wrong?

    I am also pasting text here for quick reference.

    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Click event of dynamically created label

    I did say 'Textbox drawing object rather than an ActiveX control'...
    More like this:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Click event of dynamically created label

    Thanks Romperroster

    That does what I was looking for.

    I am adding these text boxes dynamically.
    In a loop, I will check some conditions and if they are satisfied, I would add a new row at row 3, and insert this text box there.

    When the user clicks a text box, I need to identify which text box (which row) is clicked,and delete that row.

    e.g. In attached sheet, if second label is clicked, I want to delete row 5 (with name B)

    Upon clicking a label, how can I find out (in RemoveClicked procedure) the row whose text box is clicked?

    P.S. : To run and test, delete column I, and click the button.

    I am also copy-pasting code here (though not much different from your code) for quick reference:-

    Please Login or Register  to view this content.
    thx
    Ajay
    Attached Files Attached Files

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Click event of dynamically created label

    Use the TopLeftCell property

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  7. #7
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Click event of dynamically created label

    Wow!!!!
    This forum is full of geniuses!!
    Thanks, Andy Pope.

+ 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