Text wraping on edit box of dialogsheet

I have created a form with an editbox and what I need to do is to make the text content wrap rather than continuing on to the right past the size of the box. Any ideas welcome please.

With DialogSheets("FormAdd")
.EditBoxes("Edit Box 144").Text = ""
.Show
End With



Answer this question

Text wraping on edit box of dialogsheet

  • TerriM

    Interesting, just turning the MultiLine on (and not using the code you supplied) makes the text wrap as I want. The height of the box is more than sufficient but it seems to limit content to what's probably 256 characters (didn't count them). Is there a simple way to extend this to allow more characters to be entered How would this be reflected on my original code for loading the form as there are no property setitings covering this

  • Ray Fernandez379013

    rabbitoh,

    What software you developing in

    DialogSheet and EditBoxes sound like older versions of forms and text boxes, this might explain the 256 character limit.



  • AlexPil

    Hi,

    Check if the EditBox has a WordWrap property, if it does set it to true. If it doesn't then it might have something equivalent, like maybe a Wrap property, if it doesn't then it won't be possible unless you implement the wrapping logic yourself.

    .EditBoxes("Edit Box 144").WordWrap = True



  • KentaroM

    How exactly would I use this in conjuction with the existing .Text = ""

    The line of code doesn't work on its own either even in the absence of the .text line.

  • The MaiN MaN

    MS Excel 2002 VBA but I am using form and code module templates that I created a few version back, which still work just fine. Rather then reinventing the wheel each time I just recycle and modify to suit but occasionally, I run into a variation - such as this word-wrap or Multiline issue (which now solves the wrapping problem), that presents an obstacle.

    T

  • WillTurner

    As Derek mentioned in his answer. Set WordWrap to true.

    Also set MultiLine to True, but this will only work if the height of the textbox is sufficient to accomodate the lines of text.

    In the example blow the textbox width was 72.

    This should get you on your way.

    Private Sub TextBox1_Change()
    origHeight = 15
    textlen = Int(Len(TextBox1.Text) / 15) + 1
    TextBox1.Height = origHeight * textlen
    End Sub

    You'll have to play around with the figures but it will produce what you need.

    ChasAA


  • Morten Dahl

    I have updated the way I do my forms. Instead of right-clicking on a worksheet tab and inserting a dialog sheet, I have inserted a userform in the visual basic editor window. As I type, the code you provided progressivly increases the size of the data field way in advance of my typing. Running the form without the code and ensuring MultiLine is set to true, enables the form to work as required though, however you did lead me to the solution and that is appreciated. Thank you.

  • Text wraping on edit box of dialogsheet