Name
shapes.AddLabel(Orientation, Left, Top, Width, Height)
Synopsis
Draws a text box without a border and returns the label’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 label and to set the formatting of the text. The following code draws a label on the active sheet:
Sub DrawLabel( )
Dim s As Shape
' Create label (height/width will be set automatically).
Set s = ActiveSheet.Shapes.AddLabel(msoTextOrientationHorizontal, _
100, 100, 1, 1)
s.TextFrame.Characters.text = "This is some label text"
End SubThe Width and Height arguments in the preceding code are required but arbitrary because the TextFrame object’s AutoSize property is True by default. The label is automatically resized to fit the text.
Become 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