+ Reply to Thread
Results 1 to 10 of 10

ActiveX label Controls

  1. #1
    Registered User
    Join Date
    12-27-2019
    Location
    Blue Ash Ohio
    MS-Off Ver
    Windows 10 Excel 2010
    Posts
    11

    ActiveX label Controls

    Rookie Question: How do I refer to an ActiveX label that I just created. I use this code which I largely lifted off the web. My worksheet name is "Timeline".
    The overall code is adding many labels positioned over lines throughout the timeline. As I create each line, I want to put the label centered over the line.

    Please Login or Register  to view this content.
    What I would like to do is find the width of the label once it has been autosized. I will use that width to position the label accurately.
    The problem is that I don't know how to refer to this label to get the width property.

    Thanks in advance for your help.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: ActiveX label Controls

    .
    ActiveX labels are named : "Label1" ... "Label2" ... etc.

    If the label is positioned directly on Sheet1 ... place your code in the Sheet Level Module, by right clicking the Sheet1 Tab
    and select "VIEW CODE".

    This macro will change the back color of Label1 to green :

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-27-2019
    Location
    Blue Ash Ohio
    MS-Off Ver
    Windows 10 Excel 2010
    Posts
    11

    Re: ActiveX label Controls

    I have applied this suggestion and it does as you suggest. My extended question is: How do I generalize this? I will be creating dozens of labels (label1, label2...labeln). After each label creation, I need to refer back to the most recently created label to get it's particular width since they will all differ. So I need a generalized non-hard coded way to refer to the most recently created label.

    Also, as a follow on to your reply, does this need to be done on the sheet or can it be coded in a module. It's not a big deal for me. Just need to know.

    Thanks

    Mark

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ActiveX label Controls

    If you're still building this, I strongly urge you to use forms controls labels rather than ActiveX - ActiveX controls on worksheets are asking for trouble:

    You're better off not using ActiveX controls on worksheets at all. They're incredibly unstable have a look here https://www.google.co.uk/webhp?sourc...eet%20controls and by using them, you're asking for trouble.

    Forms controls are much more reliable - they're in the same dropdown as the ActiveX ones, but are designed for use on worksheets - so you don't run into any stability issues, you can do most of the same things with them too and you can use them without using code.

  5. #5
    Registered User
    Join Date
    12-27-2019
    Location
    Blue Ash Ohio
    MS-Off Ver
    Windows 10 Excel 2010
    Posts
    11

    Re: ActiveX label Controls

    Thanks for the warning. My only reason for going to ActiveX controls is the ability to control width of the label in order to center it in code. It's aesthetic. However, based on yours and other's input from things I read on the web, I will return to form controls. If you have any ideas on how to specify width of the form control (again, so I can center the label), I would appreciate it.

    Thanks very much,

    Mark

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ActiveX label Controls

    You could use a shape with text in

  7. #7
    Registered User
    Join Date
    12-27-2019
    Location
    Blue Ash Ohio
    MS-Off Ver
    Windows 10 Excel 2010
    Posts
    11

    Re: ActiveX label Controls

    I am open to that. I was investigating recently but again, as a relative rookie, I was unable to get it to work. Do you have a sample of code or a good link that explains it well.

  8. #8
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: ActiveX label Controls

    Administrative note
    Please update your profile as necessary to properly reflect the exact version(s) of Excel your question relates to. Members tailor answers based on your Excel version. Your profile does not indicate your version. ( only Windows 10)
    Thanks

  9. #9
    Registered User
    Join Date
    12-27-2019
    Location
    Blue Ash Ohio
    MS-Off Ver
    Windows 10 Excel 2010
    Posts
    11

    Re: ActiveX label Controls

    Good catch. Done. Thanks.

  10. #10
    Registered User
    Join Date
    12-27-2019
    Location
    Blue Ash Ohio
    MS-Off Ver
    Windows 10 Excel 2010
    Posts
    11

    Re: ActiveX label Controls

    Ok, I really need an answer to this question so I will ask again. Everything I read on the web seems conflicting.
    Excel Version: 2010
    Subject: Using a form control label in Excel.
    Note: I am not placing the label in a user form but rather on a spreadsheet. This is because there is excel functionality that I need to take advantage of rather than reinventing.

    With that backdrop:
    Is it possible to find or to adjust the width of a form label in code? Is it possible to autosize a form label? It is NOT acceptable to oversize the label for all circumstances because I am trying to center the label.

    my code:
    Please Login or Register  to view this content.
    I am trying to center the label over a line that I create in code. I am open to using the line shape text but don't know how to do that. I apologize for the simplicity of this question. I have made tremendous strides in getting this program working but I am stumped by the simplest stumbling block here. Any help would be greatly appreciated.

+ 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. Form Controls v. ActiveX Controls
    By Richard Stringfellow in forum Excel General
    Replies: 2
    Last Post: 01-11-2016, 08:06 PM
  2. Form & ActiveX Controls
    By John Bates in forum Excel General
    Replies: 11
    Last Post: 03-05-2011, 03:59 PM
  3. ActiveX controls
    By ell123 in forum Excel General
    Replies: 1
    Last Post: 08-21-2009, 12:10 PM
  4. Form controls vs. ActiveX controls
    By wmorrison49 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2008, 10:59 AM
  5. Activex Controls in Excel
    By tqm1 in forum Excel General
    Replies: 0
    Last Post: 04-30-2007, 09:06 PM
  6. [SOLVED] ActiveX Controls vs Form Controls
    By Alex in forum Excel General
    Replies: 1
    Last Post: 01-11-2006, 04:50 AM
  7. activex controls
    By Gary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2005, 06:12 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