shapes.AddTextbox(Orientation, Left, Top, Width, Height)


Draws a text box surrounded by a rectangular border and returns the text box’s Shape object.




An msoTextOrientation constant. Can be msoTextOrientationDownward, msoTextOrientationHorizontal, msoTextOrientationHorizontalRotatedFarEast, msoTextOrientationMixed, msoTextOrientationUpward, msoTextOrientationVertical, or msoTextOrientationVerticalFarEast.


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 Sub

Get Programming Excel with VBA and .NET now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.