Shapes.AddLabel メソッド (Word)

文字列ラベルを描画キャンバスに追加します。

構文

AddLabel (OrientationLeftTopWidthHeight)

expression 必須です。 Shapes オブジェクトを表す変数。

パラメーター

名前 必須 / オプション データ型 説明
Orientation 必須 MsoTextOrientation 文字列の向きを指定します。
Left 必須 単精度浮動小数点型 (Single) ラベルの左端の位置を、描画キャンバスの左端からポイント単位で指定します。
Top 必須 単精度浮動小数点型 (Single) ラベルの上端の位置を、描画キャンバスの上端からポイント単位で指定します。
Width 必須 単精度浮動小数点型 (Single) ラベルの幅をポイント単位で指定します。
Height 必須 単精度浮動小数点型 (Single) ラベルの高さをポイント単位で指定します。

戻り値

図形

次の使用例は、"Hello World" という青色の文字列ラベルを現在の文書に追加します。

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

関連項目

Shapes コレクション オブジェクト

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。