+ Reply to Thread
Results 1 to 6 of 6

Get Current Control's Name

  1. #1
    Registered User
    Join Date
    02-15-2011
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    21

    Get Current Control's Name

    Is it possible to retrieve the current object's name and maybe even the type of object?
    For example in:

    Please Login or Register  to view this content.
    Thanks for your help.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Get Current Control's Name

    I don't see why you need it in this context. The Sub that you showed is exclusively for an event for the combobox object called cboCity, so why would you need to dynamically determine this? It will always be the same result.

    Nevertheless,
    Please Login or Register  to view this content.
    But ControlName will always be "cboCity" and ControlType will always be "ComboBox".
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-15-2011
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Get Current Control's Name

    so why would you need to dynamically determine this?
    Because I've created a sub which takes the control name and its type as parameters.

  4. #4
    Registered User
    Join Date
    02-15-2011
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Get Current Control's Name

    I've just noticed that if the current control is in a frame, it returns the name of the frame.
    Is this a bug?

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Get Current Control's Name

    I doubt it's a bug because it has been that way a long time. But I don't know the rationale.

    Here is one workaround:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Get Current Control's Name

    It's not a bug, VBA is very 'choosy' and if needed would like to know 'where the control is'
    You could also query for every control in Framex where the xis the number of the frame.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Set PivotTable Filter to Current Day, Current Week, Current Month, or Current Year
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2014, 08:31 AM
  2. [SOLVED] copy and paste in current active cell, and need current date then scroll down 140 lines
    By vengatvj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2013, 03:40 AM
  3. Saving file to its current location and current file name with current date and "FINAL"
    By ironwill20 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2012, 03:22 AM
  4. [SOLVED] Spin Button to control the current row
    By adam2308 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2012, 04:09 PM
  5. Macro to sort an activity sheet by current week and current + last 1 and 2 weeks
    By engineering_excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2011, 11:28 AM
  6. Date Picker Control will not display Current Date
    By SP Brian in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-04-2011, 01:33 PM
  7. Can I control Macro run automatically current worksheet?
    By Microlong in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2005, 09:06 AM

Tags for this Thread

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