Ask a questionAsk a question
 

AnswerTextBox Vertical Allignment

  • Tuesday, November 03, 2009 10:51 AMmartin.thardis Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Friends,

    I was looking for similar threads but couln't find a good answer. I am trying to display the contents of a textbox aligned vertically and horizontally as centred but seems theres no vertical alignment.

    Some other thread had this snippet:

    TextBox1.TextAlign = fmTextAlignCenter
    TextBox1.AutoSize = True

    but this has caused the textbox resize to fit the contents rather then centre the text.
    Is there an easy way to do it as my textboxes are looking silly - they are big with small writing at the top of them?!?

    Any help would be very much appreciated.
    Thnaks guys!


    Marcin

Answers

  • Wednesday, November 04, 2009 11:31 AMAndy PopeMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Still need a little more information. Is that a textbox from the Controls Toolbar, if so vertical alignment is not supported.
    Or a Textbox from the Drawings toolbar, in which case something like this

        With ActiveSheet.Shapes("Text Box 1")
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
        End With
    
    

    Cheers www.andypope.info

All Replies

  • Tuesday, November 03, 2009 2:31 PMAndy PopeMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    To stop the textbox resizing do not use the AutoSize = True code.

    What type of textbox are you talking about? On a userform or worksheet, ActiveX control or Drawing shape?
    Cheers www.andypope.info
  • Wednesday, November 04, 2009 10:29 AMmartin.thardis Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Andy,

    sorry should been more specific - it is a TextBox within a worksheet.

    Marcin
  • Wednesday, November 04, 2009 11:31 AMAndy PopeMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Still need a little more information. Is that a textbox from the Controls Toolbar, if so vertical alignment is not supported.
    Or a Textbox from the Drawings toolbar, in which case something like this

        With ActiveSheet.Shapes("Text Box 1")
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
        End With
    
    

    Cheers www.andypope.info
  • Wednesday, November 04, 2009 4:17 PMmartin.thardis Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It is a TextBox from within Control Toolbar - so it wont be supported ?!?

    That is so surprising...

    Thank you very much Andy!
    All the best!
    Marcin