ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   use VBA to tell if all the text in a TextBox or TextFrame can be displayed (https://www.excelbanter.com/excel-programming/385294-use-vba-tell-if-all-text-textbox-textframe-can-displayed.html)

[email protected]

use VBA to tell if all the text in a TextBox or TextFrame can be displayed
 
Is there a way to use VBA to determine if a TextBox or TextFrame
object is sized large enough to display all the text it contains?

Thanks,

Brian Murphy


NickHK

use VBA to tell if all the text in a TextBox or TextFrame can be displayed
 
Brian,
Not great, but maybe this can get you started:

'Assumes 2 textboxes on a WS
Private Sub CommandButton3_Click()

'Add a lot of text to TextBox1
TextBox1.Text = "Add a lot of text to TextBox1" & vbNewLine & "Add a lot of
text to TextBox1" & vbNewLine & "Add a lot of text to TextBox1" & vbNewLine
& "Add a lot of text to TextBox1"

With TextBox2
.AutoSize = False
.Text = TextBox1.Text
.AutoSize = True
If .Height TextBox1.Height Then
MsgBox "Text does not fit"
End If
End With

End Sub

NickHK

wrote in message
ups.com...
Is there a way to use VBA to determine if a TextBox or TextFrame
object is sized large enough to display all the text it contains?

Thanks,

Brian Murphy





All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com