Shapes.AddLabel method (Word)

Adds a text label to a drawing canvas.

Syntax

expression.AddLabel (Orientation, Left, Top, Width, Height)

expression Required. A variable that represents a Shapes object.

Parameters

Name Required/Optional Data type Description
Orientation Required MsoTextOrientation The orientation of the text.
Left Required Single The position, measured in points, of the left edge of the label relative to the left edge of the drawing canvas.
Top Required Single The position, measured in points, of the top edge of the label relative to the top edge of the drawing canvas.
Width Required Single The width of the label, in points.
Height Required Single The height of the label, in points.

Return value

Shapes

Example

This example adds a blue text label with the text "Hello World" to a new drawing canvas in the active document.

Sub NewCanvasTextLabel() 
 Dim shpCanvas As Shape 
 Dim shpLabel As Shape 
 
 'Add a drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes.AddCanvas _ 
 (Left:=100, Top:=75, Width:=150, Height:=200) 
 
 'Add a label to the drawing canvas 
 Set
shpLabel = shpCanvas.CanvasItems.AddLabel _ 
 (Orientation:=msoTextOrientationHorizontal, _ 
 Left:=15, Top:=15, Width:=100, Height:=100) 
 
 'Fill the label textbox with a color, 
 'add text to the label and format it 
 With
shpLabel 
 With .Fill 
 .BackColor.RGB = RGB(Red:=0, Green:=0, Blue:=192) 
 'Make the fill visible 
 .Visible = msoTrue 
 End With 
 With .TextFrame.TextRange 
 .Text = "Hello World." 
 .Bold = True 
 .Font.Name = "Tahoma" 
 End With 
 End With 
End Sub

See also

Shapes Collection Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.