Name
shapes.AddTextbox(Orientation, Left, Top, Width, Height)
Synopsis
Draws a text box surrounded by a rectangular border and returns the text box’s Shape object.
|
Argument |
Settings |
|---|---|
|
|
An |
|
|
The horizontal position of the shape in points. |
|
|
The vertical position of the shape in points. |
|
|
The width of the shape in points. |
|
|
The height of the shape in points. |
Use the TextFrame property to get or set the text in the shape and to set the formatting of the text. Unlike labels, text boxes do not automatically resize to fit their text. You must set the AutoSize property as shown here:
Sub DrawTextbox( )
Dim ws As Worksheet, s As Shape
Set ws = ActiveSheet
' Create label (height/width will be set by AutoSize).
Set s = ws.Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 1, 1)
s.TextFrame.Characters.text = "This is some label text"
' Resize text box to fit text.
s.TextFrame.AutoSize = True
End SubBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access