Text Box Length

G

Guest

I created a macro that auto sizes a text box. I would like for the macro to
tell me the length of that text box. (I believe this is simply the number of
characters in the text box.) How do I do this? Thanks in advance for any
suggestions.
 
A

Ardus Petus

The width (in points) will be returned by .Width property of the listbox.
Caution: if empty, the listbox seems to have a minimum width of 12.75
The width is dependent upon the characters' with with proportional fonts:
'0000000000 will give a larger width than iiiiiiiiii

HTH
 
G

Guest

Can you give an example of the .width command? I can't get it to work. I
also can't get the .TextLength command to work. I'm not sure how to use it.
Here is the code that auto sizes the box.

Sub testing()

ActiveSheet.Shapes("Text Box 1").Select
With Selection
.AutoSize = True
End With

End Sub

Thanks.
 
A

Ardus Petus

Sub testing()

ActiveSheet.Shapes("Text Box 1").Select
With Selection
.AutoSize = True
msgbox "Width = " & .Width
End With

End Sub

HTH
 
G

Guest

Maybe this........

Sub size()
ActiveSheet.Shapes("Text Box 1").Select
With Selection
.AutoSize = True
MsgBox .Width
End With
End Sub

Vaya con Dios,
Chuck, CABGx3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top