Results 1 to 9 of 9
  1. #1
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    280

    Change font and point size in an Active-X Textbox

    I have an Active-X Textbox on one of my forms (don't ask why I am not using an ordinary textbox in this case).
    I am trying to change the font and point size, but there does not seem to be a Font field on the properties sheet.
    I am sure this must be simple, but can't figure it out and have googled without success. All answers seem to relate to Excel.



    Anyone know how to do this.

    p.s. The colours seem a bit odd as well e.g. BackColor = -2147483643 with no option to change. However, I can change this to what I want from VBA, so this is not a problem.

  2. #2
    Join Date
    Jun 2022
    Posts
    28
    Quote Originally Posted by Miles R View Post
    I have an Active-X Textbox on one of my forms
    Is this the Microsoft Forms 2.0 TextBox?

    Code:
        Dim f As Object
    
    
        Set f = New NewFont
        f.Name = "Consolas"
        f.Size = 12
        Set TextBox1.Font = f

  3. #3
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Thanks for the reply. When I created the Active X text box, I used the Active X control which was called Microsoft Forms 2.0 TextBox
    The Property Sheet shows it as Active X Control.

    The above code does not seem to work for this type of text box. It says property not supported and there is no Font option in the properties like for a normal textbox.
    If there were, I would just have set the Font at design time and would not need any code.

    p.s. Tried to upload an image of the Properties Sheet, but it would not work, nor could I just cut and paste and image. Seems to have disappeared.

  4. #4
    Join Date
    Jun 2022
    Posts
    28
    It says property not supported and there is no Font option in the properties like for a normal textbox.
    If there were, I would just have set the Font at design time and would not need any code.
    There are no provisions to set the font at design time.
    It must be done through code.

    Take a look at your Object Browser (Press [F2] in the VBE).

    Look at the TextBox class of the MSForms Library for details.

    Click image for larger version. 

Name:	VBE_Object-Browser.png 
Views:	14 
Size:	33.6 KB 
ID:	52277


  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    You need to add images or any files as attachments.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Thanks for that, although I wonder why there is the option to Insert Image and Copy and Paste. When I tried this, it looked like it had worked - the image briefly appeared below the text, but when posted it had gone.
    However, this is by-the-by for the posted question.

  7. #7
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Thanks again the for the reply. Yes it does look like there are no provisions for this at design time and I can see the Font option you have shown above in the Object Browser, but I am not convinced this applies to an Active-X textbox.
    When I try with the code you supplied
    Code:
        Set f = New NewFont
        f.Name = "Consolas"
        f.Size = 12
        Me.txtSubbreedingRange.Font = f
    I get the errorClick image for larger version. 

Name:	Capture2.JPG 
Views:	14 
Size:	29.6 KB 
ID:	52278

    This is on the Me.txtSubbreedingRange.Font = f line

  8. #8
    Join Date
    Jun 2022
    Posts
    28
    Quote Originally Posted by Miles R View Post
    Code:
        Me.txtSubbreedingRange.Font = f
    The line should be:

    Code:
    SET Me.txtSubbreedingRange.Font = f

  9. #9
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Ah - I did not spot the SET bit - must have assumed it was the same for a normal text box.

    Great, that works, I'll make this thread as solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 11-08-2021, 03:03 PM
  2. Replies: 13
    Last Post: 10-26-2019, 06:06 PM
  3. Replies: 12
    Last Post: 01-12-2019, 06:02 PM
  4. Replies: 4
    Last Post: 08-03-2014, 10:10 PM
  5. Replies: 11
    Last Post: 11-28-2012, 05:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums