I have a UserForm
with a TextBox
(among other controls). MultiLine
and WordWrap
are enabled. When I enter text into the TextBox
, the line wraps at the right end of the line, and continues to do so till the TextBox
is full, at which point a vertical scrollbar appears. All this is normal and works.
I wish to detect when the box is full so that I can trigger a macro.
I thought of using a 'change' event for the TextBox, to check if the vertical scrollbar is active, but I cannot find away to detect whether the scrollbar is visible. If I could detect this, I could use the activation of the scrollbar to achieve the desired end goal.
I assume the Textbox's Height is stable and you do not need to change it.
Then you could try the following.
Insert text until your TextBox is full and count the visible lines.
For this example I'll guess they are 5.
Then in the Change event of the TextBox put the following.
Private Sub TextBox1_Change()
If Me.TextBox1.LineCount > 5 Then
'fire your macro here
End If
End Sub