0 out of 1 rated this helpful - Rate this topic

AddTextbox Method

Office 2003

Adds a text box to a drawing canvas. Returns a Shape object that represents the text box and adds it to the CanvasShapes collection.

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

expression Required. An expression that returns a CanvasShapes object.

MsoTextOrientation can be one of these MsoTextOrientation constants.
msoTextOrientationDownward
msoTextOrientationHorizontal
msoTextOrientationHorizontalRotatedFarEast
msoTextOrientationMixed
msoTextOrientationUpward
msoTextOrientationVertical
msoTextOrientationVerticalFarEast

Left    Required Single. The position, measured in points, of the left edge of the text box.

Top    Required Single. The position, measured in points, of the top edge of the text box.

Width    Required Single. The width, measured in points, of the text box.

Height    Required Single. The height, measured in points, of the text box.

Adds a text box to a document. Returns a Shape object that represents the text box and adds it to the Shapes collection.

expression.AddTextbox(Orientation, Left, Top, Width, Height, Anchor)

expression Required. An expression that returns one of the objects in the Applies to list.

MsoTextOrientation can be one of these MsoTextOrientation constants.
msoTextOrientationDownward
msoTextOrientationHorizontal
msoTextOrientationHorizontalRotatedFarEast
msoTextOrientationMixed
msoTextOrientationUpward
msoTextOrientationVertical
msoTextOrientationVerticalFarEast

Left    Required Single. The position, measured in points, of the left edge of the text box.

Top    Required Single. The position, measured in points, of the top edge of the text box.

Width    Required Single. The width, measured in points, of the text box.

Height    Required Single. The height, measured in points, of the text box.

Anchor     Optional Variant. A Range object that represents the text to which the text box is bound. If Anchor is specified, the anchor is positioned at the beginning of the first paragraph in the anchoring range. If this argument is omitted, the anchoring range is selected automatically and the text box is positioned relative to the top and left edges of the page.

Example

This example add a textbox to a canvas in a new document.

Sub NewCanvasTextbox()
    Dim docNew As Document
    Dim shpCanvas As Shape

    'Create a new document and add a drawing canvas
    Set docNew = Documents.Add
    Set shpCanvas = docNew.Shapes.AddCanvas _
        (Left:=100, Top:=75, Width:=150, Height:=200)

    'Add a text box to the drawing canvas
    shpCanvas.CanvasItems.AddTextbox _
        Orientation:=msoTextOrientationHorizontal, _
        Left:=1, Top:=1, Width:=100, Height:=100
End Sub
				

This example adds a text box that contains the text "Test" to a new document.

Sub newTextbox()
    Dim docNew As Document
    Dim newTextbox As Shape

    'Create a new document and add a text box
    Set docNew = Documents.Add
    Set newTextbox = docNew.Shapes.AddTextbox _
        (Orientation:=msoTextOrientationHorizontal, _
        Left:=100, Top:=100, Width:=300, Height:=200)

    'Add text to the text box
    newTextbox.TextFrame.TextRange = "Test"
End Sub
				




Did you find this helpful?
(1500 characters remaining)