Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default UserForm TextBox with fixed Width and dynamic Height

Hello,

Can we have a multi line TextBox in a Userform with fixed width but the
height adjusting according to the length of text? Say if the textbox
contains text to be fit in five lines then adjust the height
accrdingly? also with a maximum height fixed, so that it may not be
more than the height of the userfom itself.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default UserForm TextBox with fixed Width and dynamic Height

Hi Soniya,

like this:

Private Sub TextBox1_Change()
TextBox1.Width = 100
' to restrict autosize to vertical
If TextBox1.Height 75 Then
TextBox1.Height = 75
TextBox1.AutoSize = False
End If
End Sub


plus
multiline = true
autosize = true
wordwrap = true

Unfortunately, when typing some lines of text,
the first line vanishes temporarily,
but reappears when the textbox looses focus.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Just fooling around with Excel a bit

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default UserForm TextBox with fixed Width and dynamic Height

You could play around a bit with it, by adjusting the height by the number
of characters, but I doubt that you can be totally accurate as it depends
upon where the word breaks.

Private Sub TextBox1_Change()
With Me.TextBox1
.Height = Application.Min(Me.Height - 32, (Int(Len(.Text) /
Int(.Width / 4.7)) + 1) * 18)
End With
End Sub

should get you started on the idea, but you will need to play with the
variables to suit.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Soniya" wrote in message
oups.com...
Hello,

Can we have a multi line TextBox in a Userform with fixed width but the
height adjusting according to the length of text? Say if the textbox
contains text to be fit in five lines then adjust the height
accrdingly? also with a maximum height fixed, so that it may not be
more than the height of the userfom itself.

Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rows & Columns Fixed Width / Height Elgee Excel Discussion (Misc queries) 2 August 22nd 08 10:19 PM
Fixed width fonts Also Excel Discussion (Misc queries) 3 January 8th 08 04:42 PM
Cells Fixed height and width Rayelle Excel Discussion (Misc queries) 1 January 23rd 07 12:19 AM
Dynamic update of UserForm TextBox Tom_C Excel Programming 7 January 15th 04 06:58 PM
Fixed Width - Opening Certain Fixed Width Files Jan[_8_] Excel Programming 2 December 30th 03 08:31 PM


All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"