Add related procedures in class Shape (Word VBA)

This page presents procedures from class Shape related to the theme Add: CanvasShapes.AddCallout, CanvasShapes.AddConnector, CanvasShapes.AddCurve, CanvasShapes.AddLabel, CanvasShapes.AddLine, CanvasShapes.AddPicture, CanvasShapes.AddPolyline, CanvasShapes.AddShape, CanvasShapes.AddTextbox, CanvasShapes.AddTextEffect, Shapes.Add3DModel, Shapes.AddCallout, Shapes.AddCanvas, Shapes.AddChart2, Shapes.AddCurve, Shapes.AddLabel, Shapes.AddLine, Shapes.AddOLEControl, Shapes.AddOLEObject, Shapes.AddPicture, Shapes.AddPolyline, Shapes.AddShape, Shapes.AddSmartArt, Shapes.AddTextbox, Shapes.AddTextEffect and Shapes.AddWebVideo

CanvasShapes.AddCallout

Adds a borderless line callout to a drawing canvas. Returns a Shape object that represents the callout.

You can insert a greater variety of callouts, such as balloons and clouds, using the AddShape method.

Syntax : expression.AddCallout (Type, Left, Top, Width, Height)

Sub NewCanvasCallout() 
 Dim shpCanvas As Shape 
 
 'Add drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes.AddCanvas _ 
 (Left:=150, Top:=150, Width:=200, Height:=300) 
 
 'Add callout to the drawing canvas 
 shpCanvas.CanvasItems.AddCallout _ 
 Type:=msoCalloutTwo, Left:=100, _ 
 Top:=40, Width:=150, Height:=75 
End Sub

Arguments

The following arguments are required:

Type (Office.MsoCalloutType) - The type of callout.

Left (Single) - The position, in points, of the left edge of the callout's bounding box.

Top (Single) - The position, in points, of the top edge of the callout's bounding box.

Width (Single) - The width, in points, of the callout's bounding box.

Height (Single) - The height, in points, of the callout's bounding box.

CanvasShapes.AddConnector

Returns a Shape object that represents a connecting line between two shapes in a drawing canvas.

Syntax : expression.AddConnector (Type, BeginX, BeginY, EndX, EndY)

Sub AddCanvasConnector() 
 
 Dim docNew As Document 
 Dim shpCanvas As Shape 
 
 Set docNew = Documents.Add 
 
 'Add drawing canvas to new document 
 Set shpCanvas = docNew.Shapes.AddCanvas( _ 
 Left:=150, Top:=150, Width:=200, Height:=300) 
 
 'Add connector to the drawing canvas 
 shpCanvas.CanvasItems.AddConnector _ 
 Type:=msoConnectorStraight, BeginX:=150, _ 
 BeginY:=150, EndX:=200, EndY:=200 
 
End Sub

Arguments

The following arguments are required:

Type (Office.MsoConnectorType) - The type of connector.

BeginX (Single) - The horizontal position that marks the beginning of the connector.

BeginY (Single) - The vertical position that marks the beginning of the connector.

EndX (Single) - The horizontal position that marks the end of the connector.

EndY (Single) - The vertical position that marks the end of the connector.

CanvasShapes.AddCurve

Returns a Shape object that represents a Bézier curve in a drawing canvas.

Syntax : expression.AddCurve (SafeArrayOfPoints)

SafeArrayOfPoints: An array of coordinate pairs that specifies the vertices and control points of the curve. The first point you specify is the starting vertex, and the next two points are control points for the first Bézier segment. Then, for each additional segment of the curve, you specify a vertex and two control points. The last point you specify is the ending vertex for the curve. Note that you must always specify 3n + 1 points, where n is the number of segments in the curve.

Sub CanvasBezier() 
 
 Dim docNew As Document 
 Dim shpCanvas As Shape 
 Dim sngArray(1 To 7, 1 To 2) As Single 
 
 Set docNew = Documents.Add 
 
 'Create a new drawing canvas 
 Set shpCanvas = docNew.Shapes.AddCanvas(Left:=100, _ 
 Top:=100, Width:=300, Height:=50) 
 
 sngArray(1, 1) = 0 
 sngArray(1, 2) = 0 
 sngArray(2, 1) = 50 
 sngArray(2, 2) = 50 
 sngArray(3, 1) = 100 
 sngArray(3, 2) = 0 
 sngArray(4, 1) = 150 
 sngArray(4, 2) = 50 
 sngArray(5, 1) = 200 
 sngArray(5, 2) = 0 
 sngArray(6, 1) = 250 
 sngArray(6, 2) = 50 
 sngArray(7, 1) = 300 
 sngArray(7, 2) = 0 
 
 'Add Bezier curve to drawing canvas 
 shpCanvas.CanvasItems.AddCurve _ 
 SafeArrayOfPoints:=sngArray 
 
End Sub

CanvasShapes.AddLabel

Adds a text label to a drawing canvas. Returns a Shapes object that represents the text label.

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

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

Arguments

The following arguments are required:

Orientation (Office.MsoTextOrientation) - The orientation of the text.

Left (Single) - The position, measured in points, of the left edge of the label relative to the left edge of the drawing canvas.

Top (Single) - The position, measured in points, of the top edge of the label relative to the top edge of the drawing canvas.

Width (Single) - The width of the label, in points.

Height (Single) - The height of the label, in points.

CanvasShapes.AddLine

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

To create an arrow, use the Line property to format a line.

Syntax : expression.AddLine (BeginX, BeginY, EndX, EndY)

Sub NewCanvasLine() 
 Dim shpCanvas As Shape 
 Dim shpLine As Shape 
 
 'Add new drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes _ 
 .AddCanvas(Left:=100, Top:=75, _ 
 Width:=150, Height:=200) 
 
 'Add a line to the drawing canvas 
 Set shpLine = shpCanvas.CanvasItems.AddLine( _ 
 BeginX:=25, BeginY:=25, EndX:=150, EndY:=150) 
 
 'Add an arrow to the line and sets the color to purple 
 With shpLine.Line 
 .BeginArrowheadStyle = msoArrowheadDiamond 
 .BeginArrowheadWidth = msoArrowheadWide 
 .ForeColor.RGB = RGB(Red:=150, Green:=0, Blue:=255) 
 End With 
End Sub

Arguments

The following arguments are required:

BeginX (Single) - The horizontal position, measured in points, of the line's starting point, relative to the drawing canvas.

BeginY (Single) - The vertical position, measured in points, of the line's starting point, relative to the drawing canvas.

EndX (Single) - The horizontal position, measured in points, of the line's endpoint, relative to the drawing canvas.

EndY (Single) - The vertical position, measured in points, of the line's endpoint, relative to the drawing canvas.

CanvasShapes.AddPicture

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

Syntax : expression.AddPicture (FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height)

Sub NewCanvasPicture() 
 Dim shpCanvas As Shape 
 
 'Add a drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes _ 
 .AddCanvas(Left:=100, Top:=75, _ 
 Width:=200, Height:=300) 
 
 'Add a graphic to the drawing canvas 
 shpCanvas.CanvasItems.AddPicture _ 
 FileName:="C:\Program Files\Microsoft Office\" & _ 
 "Office\Bitmaps\Styles\stone.bmp", _ 
 LinkToFile:=False, SaveWithDocument:=True 
End Sub

Arguments

The following argument is required

FileName (String) - The path and file name of the picture.

The following arguments are optional

LinkToFile (Boolean) - True to link the picture to the file from which it was created. False to make the picture an independent copy of the file. The default value is False.

SaveWithDocument (Boolean) - True to save the linked picture with the document. The default value is False.

Left (Long) - The position, measured in points, of the left edge of the new picture relative to the drawing canvas.

Top (Long) - The position, measured in points, of the top edge of the new picture relative to the drawing canvas.

Width (Long) - The width of the picture, in points.

Height (Long) - The height of the picture, in points.

CanvasShapes.AddPolyline

Adds an open or closed polygon to a drawing canvas. Returns a Shape object that represents the polygon.

To form a closed polygon, assign the same coordinates to the first and last vertices in the polyline drawing.

Syntax : expression.AddPolyline (SafeArrayOfPoints)

SafeArrayOfPoints: An array of coordinate pairs that specifies the polyline drawing's vertices.

Sub NewCanvasPolyline() 
 Dim docNew As Document 
 Dim shpCanvas As Shape 
 Dim sngArray(1 To 3, 1 To 2) As Single 
 
 'Creates a new document and adds a drawing canvas 
 Set docNew = Documents.Add 
 Set shpCanvas = docNew.Shapes.AddCanvas( _ 
 Left:=100, Top:=75, Width:=200, Height:=300) 
 
 'Sets the coordinates of the array 
 sngArray(1, 1) = 100 
 sngArray(1, 2) = 75 
 sngArray(2, 1) = 150 
 sngArray(2, 2) = 100 
 sngArray(3, 1) = 100 
 sngArray(3, 2) = 125 
 
 'Adds a V-shaped open polyline to the drawing canvas 
 shpCanvas.CanvasItems.AddPolyline SafeArrayOfPoints:=sngArray 
End Sub

CanvasShapes.AddShape

Adds an AutoShape to a drawing canvas. Returns a Shape object that represents the AutoShape.

To change the type of an AutoShape that you've added, set the AutoShapeType property.

Syntax : expression.AddShape (Type, Left, Top, Width, Height)

Sub NewCanvasShape() 
 Dim shpCanvas As Shape 
 Dim shpCanvasShape As Shape 
 
 'Add a new drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes.AddCanvas( _ 
 Left:=100, Top:=75, Width:=150, Height:=200) 
 
 'Add a circle to the drawing canvas 
 Set shpCanvasShape = shpCanvas.CanvasItems.AddShape( _ 
 Type:=msoShapeOval, Left:=25, Top:=25, _ 
 Width:=150, Height:=150) 
End Sub

Arguments

The following arguments are required:

Type (Long) - The type of shape to be returned. Can be any MsoAutoShape constant.

Left (Single) - The position, measured in points, of the left edge of the AutoShape.

Top (Single) - The position, measured in points, of the top edge of the AutoShape.

Width (Single) - The width, measured in points, of the AutoShape.

Height (Single) - The height, measured in points, of the AutoShape.

CanvasShapes.AddTextbox

Adds a text box to a drawing canvas. Returns a Shape object that represents the text box.

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

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

Arguments

The following arguments are required:

Orientation (Office.MsoTextOrientation) - The orientation of the text. Some of the MsoTextOrientation constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

Left (Single) - The position, measured in points, of the left edge of the text box.

Top (Single) - The position, measured in points, of the top edge of the text box.

Width (Single) - The width, measured in points, of the text box.

Height (Single) - The height, measured in points, of the text box.

CanvasShapes.AddTextEffect

Adds a WordArt shape to a drawing canvas. Returns a Shape object that represents the WordArt.

When you add WordArt to a document, the height and width of the WordArt are automatically set based on the size and amount of text you specify.

Syntax : expression.AddTextEffect (PresetTextEffect, Text, FontName, FontSize, FontBold, FontItalic, Left, Top)

Sub NewCanvasTextEffect() 
 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:=100, Width:=150, _ 
 Height:=50) 
 
 'Add WordArt shape to the drawing canvas 
 shpCanvas.CanvasItems.AddTextEffect _ 
 PresetTextEffect:=msoTextEffect20, _ 
 Text:="Hello, World", FontName:="Tahoma", _ 
 FontSize:=15, FontBold:=msoTrue, _ 
 FontItalic:=msoFalse, _ 
 Left:=120, Top:=120 
End Sub

Arguments

The following arguments are required:

PresetTextEffect (Office.MsoPresetTextEffect) - A preset text effect. The values of the MsoPresetTextEffect constants correspond to the formats listed in the WordArt Gallery dialog box (numbered from left to right and from top to bottom).

Text (String) - The text in the WordArt.

FontName (String) - The name of the font used in the WordArt.

FontSize (Single) - The size (in points) of the font used in the WordArt.

FontBold (Office.MsoTriState) - msoTrue to bold the WordArt font. msoFalse to set the font used in the WordArt to regular.

FontItalic (Office.MsoTriState) - msoTrue to italicize the WordArt font. msoFalse to set the font used in the WordArt to regular.

Left (Single) - The position, measured in points, of the left edge of the WordArt shape relative to the left edge of the drawing canvas.

Top (Single) - The position, measured in points, of the top edge of the WordArt shape relative to the top edge of the drawing canvas.

Shapes.Add3DModel

Adds a 3D model to a drawing canvas. Returns a Shape object that represents the 3D model and adds it to the CanvasShapes collection.

Syntax : expression.Add3DModel (FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height, Anchor)

Sub NewCanvasPicture() 
 Dim shpCanvas As Shape 
 
 'Add a drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes.AddCanvas(Left:=100, Top:=75, Width:=200, Height:=300)
 
 'Add a 3D model to the drawing canvas 
 shpCanvas.CanvasItems.Add3DModel(FileName:="c:\my 3D models\sphere.glb", LinkToFile:=False, SaveWithDocument:=True, Left:=100, Top:=100, Width:=70, Height:=70)
End Sub

Arguments

The following argument is required

FileName (String) - The path and file name of the 3D model.

The following arguments are optional

LinkToFile (Boolean) - True to link the 3D model to the file from which it was created. False to make the 3D model an independent copy of the file. The default value is False.

SaveWithDocument (Boolean) - True to save the linked 3D model with the document. The default value is False.

Left (Long) - The position, measured in points, of the left edge of the new 3D model relative to the drawing canvas.

Top (Long) - The position, measured in points, of the top edge of the new 3D model relative to the drawing canvas.

Width (Long) - The width of the 3D model, in points (enter -1 to auto-calculate a width based on the 3D model dimensions).

Height (Long) - The height of the 3D model, in points (enter -1 to auto-calculate a height based on the 3D model dimensions).

Anchor - Range

Shapes.AddCallout

Adds a borderless line callout to a drawing canvas.

You can insert a greater variety of callouts, such as balloons and clouds, by using the AddShape method.

Syntax : expression.AddCallout (Type, Left, Top, Width, Height, Anchor)

Sub NewCanvasCallout() 
 Dim shpCanvas As Shape 
 
 'Add drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes.AddCanvas _ 
 (Left:=150, Top:=150, Width:=200, Height:=300) 
 
 'Add callout to the drawing canvas 
 shpCanvas.CanvasItems.AddCallout _ 
 Type:=msoCalloutTwo, Left:=100, _ 
 Top:=40, Width:=150, Height:=75 
End Sub

Arguments

The following arguments are required:

Type (Office.MsoCalloutType) - The type of callout.

Left (Single) - The position, in points, of the left edge of the callout's bounding box.

Top (Single) - The position, in points, of the top edge of the callout's bounding box.

Width (Single) - The width, in points, of the callout's bounding box.

Height (Single) - The height, in points, of the callout's bounding box.

The following argument is optional

Anchor - Range

Shapes.AddCanvas

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

Syntax : expression.AddCanvas (Left, Top, Width, Height, Anchor)

Sub AddInlineCanvas() 
 Dim docNew As Document 
 Dim shpCanvas As Shape 
 
 Set docNew = Documents.Add 
 
 'Add a drawing canvas to the new document 
 Set shpCanvas = docNew.Shapes.AddCanvas( _ 
 Left:=150, Top:=150, Width:=70, Height:=70) 
 shpCanvas.WrapFormat.Type = wdWrapInline 
 
 'Add shapes to drawing canvas 
 With shpCanvas.CanvasItems 
 .AddShape msoShapeHeart, Left:=10, _ 
 Top:=10, Width:=50, Height:=60 
 .AddLine BeginX:=0, BeginY:=0, _ 
 EndX:=70, EndY:=70 
 End With 
 With shpCanvas 
 .CanvasItems(1).Fill.ForeColor _ 
 .RGB = RGB(Red:=255, Green:=0, Blue:=0) 
 .CanvasItems(2).Line _ 
 .EndArrowheadStyle = msoArrowheadTriangle 
 End With 
End Sub

Arguments

The following arguments are required:

Left (Single) - The position, in points, of the left edge of the drawing canvas, relative to the anchor.

Top (Single) - The position, in points, of the top edge of the drawing canvas, relative to the anchor.

Width (Single) - The width, in points, of the drawing canvas.

Height (Single) - The height, in points, of the drawing canvas.

The following argument is optional

Anchor (Range) - A Range object that represents the text to which the canvas 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 canvas is positioned relative to the top and left edges of the page.

Shapes.AddChart2

Adds a chart to the document. Returns a Shape object that represents a chart and adds it to the specified collection.

Syntax : expression.AddChart2 (Style, Type, Left, Top, Width, Height, Anchor, NewLayout)

Dim shpAddChart2 As Shape
Set shpAddChart2 = Selection.HeaderFooter.Shapes.AddChart2()

Arguments

The following arguments are optional

Style (Long) - The chart style. Use "-1" to get the default style for the chart type specified in Type.

Type (Office.XlChartType) - The type of chart.

Left (Long) - The position, in points, of the left edge of the chart, relative to the anchor.

Top (Long) - The position, in points, of the top edge of the chart, relative to the anchor.

Width (Long) - The width, in points, of the chart.

Height (Long) - The height, in points, of the chart.

Anchor (Range) - A Range object that represents the text to which the canvas 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 canvas is positioned relative to the top and left edges of the page.

NewLayout (Boolean) - If NewLayout is True, the chart will be inserted by using the new dynamic formatting rules (Title is on, and Legend is on only if there are multiple series).

Shapes.AddCurve

Returns a Shape object that represents a Bézier curve in a drawing canvas.

Syntax : expression.AddCurve (SafeArrayOfPoints, Anchor)

Sub CanvasBezier() 
 
 Dim docNew As Document 
 Dim shpCanvas As Shape 
 Dim sngArray(1 To 7, 1 To 2) As Single 
 
 Set docNew = Documents.Add 
 
 'Create a new drawing canvas 
 Set shpCanvas = docNew.Shapes.AddCanvas(Left:=100, _ 
 Top:=100, Width:=300, Height:=50) 
 
 sngArray(1, 1) = 0 
 sngArray(1, 2) = 0 
 sngArray(2, 1) = 50 
 sngArray(2, 2) = 50 
 sngArray(3, 1) = 100 
 sngArray(3, 2) = 0 
 sngArray(4, 1) = 150 
 sngArray(4, 2) = 50 
 sngArray(5, 1) = 200 
 sngArray(5, 2) = 0 
 sngArray(6, 1) = 250 
 sngArray(6, 2) = 50 
 sngArray(7, 1) = 300 
 sngArray(7, 2) = 0 
 
 'Add Bezier curve to drawing canvas 
 shpCanvas.CanvasItems.AddCurve _ 
 SafeArrayOfPoints:=sngArray 
 
End Sub

Arguments

The following argument is required

SafeArrayOfPoints (Long) - An array of coordinate pairs that specifies the vertices and control points of the curve. The first point you specify is the starting vertex, and the next two points are control points for the first Bézier segment. Then, for each additional segment of the curve, you specify a vertex and two control points. The last point you specify is the ending vertex for the curve. Note that you must always specify 3n + 1 points, where n is the number of segments in the curve.

The following argument is optional

Anchor - Range

Shapes.AddLabel

Adds a text label to a drawing canvas.

Syntax : expression.AddLabel (Orientation, Left, Top, Width, Height, Anchor)

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

Arguments

The following arguments are required:

Orientation (Office.MsoTextOrientation) - The orientation of the text.

Left (Single) - The position, measured in points, of the left edge of the label relative to the left edge of the drawing canvas.

Top (Single) - The position, measured in points, of the top edge of the label relative to the top edge of the drawing canvas.

Width (Single) - The width of the label, in points.

Height (Single) - The height of the label, in points.

The following argument is optional

Anchor - Range

Shapes.AddLine

Adds a line to a drawing canvas.

To create an arrow, use the Line property to format a line.

Syntax : expression.AddLine (BeginX, BeginY, EndX, EndY, Anchor)

Sub NewCanvasLine() 
 Dim shpCanvas As Shape 
 Dim shpLine As Shape 
 
 'Add new drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes _ 
 .AddCanvas(Left:=100, Top:=75, _ 
 Width:=150, Height:=200) 
 
 'Add a line to the drawing canvas 
 Set shpLine = shpCanvas.CanvasItems.AddLine( _ 
 BeginX:=25, BeginY:=25, EndX:=150, EndY:=150) 
 
 'Add an arrow to the line and sets the color to purple 
 With shpLine.Line 
 .BeginArrowheadStyle = msoArrowheadDiamond 
 .BeginArrowheadWidth = msoArrowheadWide 
 .ForeColor.RGB = RGB(Red:=150, Green:=0, Blue:=255) 
 End With 
End Sub

Arguments

The following arguments are required:

BeginX (Single) - The horizontal position, measured in points, of the line's starting point, relative to the drawing canvas.

BeginY (Single) - The vertical position, measured in points, of the line's starting point, relative to the drawing canvas.

EndX (Single) - The horizontal position, measured in points, of the line's endpoint, relative to the drawing canvas.

EndY (Single) - The vertical position, measured in points, of the line's endpoint, relative to the drawing canvas.

The following argument is optional

Anchor - Range

Shapes.AddOLEControl

Creates an ActiveX control (formerly known as an OLE control). Returns the InlineShape object that represents the new ActiveX control.

ActiveX controls are represented as either Shape objects or InlineShape objects in Microsoft Word. To modify the properties for an ActiveX control, you use the Object property of the OLEFormat object for the specified shape or inline shape. For information about available ActiveX control class types, see OLE Programmatic Identifiers.

Syntax : expression.AddOLEControl (ClassType, Left, Top, Width, Height, Anchor)

Dim shpAddOLEControl As Shape
Set shpAddOLEControl = Selection.HeaderFooter.Shapes.AddOLEControl()

Arguments

The following arguments are optional

ClassType - The programmatic identifier for the ActiveX control to be created

Left - Long

Top - Long

Width - Long

Height - Long

Anchor - Range

Shapes.AddOLEObject

Creates an OLE object. Returns the InlineShape object that represents the new OLE object.

Syntax : expression.AddOLEObject (ClassType, FileName, LinkToFile, DisplayAsIcon, IconFileName, IconIndex, IconLabel, Left, Top, Width, Height, Anchor)

ActiveDocument.Shapes.AddOLEObject _ 
 FileName:="c:\my documents\MyDrawing.bmp", _ 
 LinkToFile:=True

Arguments

The following arguments are optional

ClassType (String) - The name of the application used to activate the specified OLE object.

FileName (String) - The file from which the object is to be created. If this argument is omitted, the current folder is used. You must specify either the ClassType or FileName argument for the object, but not both.

LinkToFile (Boolean) - True to link the OLE object to the file from which it was created. False to make the OLE object an independent copy of the file. If you specified a value for ClassType, the LinkToFile argument must be False. The default value is False.

DisplayAsIcon (Boolean) - True to display the OLE object as an icon. The default value is False.

IconFileName (String) - The file that contains the icon to be displayed.

IconIndex (Long) - The index number of the icon within IconFileName. The order of icons in the specified file corresponds to the order in which the icons appear in the Change Icon dialog box when the Display as icon check box is selected. The first icon in the file has the index number 0 (zero). If an icon with the given index number doesn't exist in IconFileName, the icon with the index number 1 (the second icon in the file) is used. The default value is 0 (zero).

IconLabel (String) - A label (caption) to be displayed beneath the icon.

Left - Long

Top - Long

Width - Long

Height - Long

Anchor - Range

Shapes.AddPicture

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

Syntax : expression.AddPicture (FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height, Anchor)

Sub NewCanvasPicture() 
 Dim shpCanvas As Shape 
 
 'Add a drawing canvas to the active document 
 Set shpCanvas = ActiveDocument.Shapes _ 
 .AddCanvas(Left:=100, Top:=75, _ 
 Width:=200, Height:=300) 
 
 'Add a graphic to the drawing canvas 
 shpCanvas.CanvasItems.AddPicture _ 
 FileName:="C:\Program Files\Microsoft Office\" & _ 
 "Office\Bitmaps\Styles\stone.bmp", _ 
 LinkToFile:=False, SaveWithDocument:=True 
End Sub

Arguments

The following argument is required

FileName (String) - The path and file name of the picture.

The following arguments are optional

LinkToFile (Boolean) - True to link the picture to the file from which it was created. False to make the picture an independent copy of the file. The default value is False.

SaveWithDocument (Boolean) - True to save the linked picture with the document. The default value is False.

Left (Long) - The position, measured in points, of the left edge of the new picture relative to the drawing canvas.

Top (Long) - The position, measured in points, of the top edge of the new picture relative to the drawing canvas.

Width (Long) - The width of the picture, in points.

Height (Long) - The height of the picture, in points.

Anchor - Range

Shapes.AddPolyline

Adds an open or closed polygon to a drawing canvas. Returns a Shape object that represents the polygon and adds it to the CanvasShapes collection.

To form a closed polygon, assign the same coordinates to the first and last vertices in the polyline drawing.

Syntax : expression.AddPolyline (SafeArrayOfPoints, Anchor)

Sub NewCanvasPolyline() 
 Dim docNew As Document 
 Dim shpCanvas As Shape 
 Dim sngArray(1 To 3, 1 To 2) As Single 
 
 'Creates a new document and adds a drawing canvas 
 Set docNew = Documents.Add 
 Set shpCanvas = docNew.Shapes.AddCanvas( _ 
 Left:=100, Top:=75, Width:=200, Height:=300) 
 
 'Sets the coordinates of the array 
 sngArray(1, 1) = 100 
 sngArray(1, 2) = 75 
 sngArray(2, 1) = 150 
 sngArray(2, 2) = 100 
 sngArray(3, 1) = 100 
 sngArray(3, 2) = 125 
 
 'Adds a V-shaped open polyline to the drawing canvas 
 shpCanvas.CanvasItems.AddPolyline SafeArrayOfPoints:=sngArray 
End Sub

Arguments

The following argument is required

SafeArrayOfPoints (Long) - An array of coordinate pairs that specifies the polyline drawing's vertices.

The following argument is optional

Anchor - Range

Shapes.AddShape

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

To change the type of an AutoShape that you've added, set the AutoShapeType property.

Syntax : expression.AddShape (Type, Left, Top, Width, Height, Anchor)

Dim lngType As Long: lngType =  
Dim shpAddShape As Shape
Set shpAddShape = Selection.HeaderFooter.Shapes.AddShape(Type:=lngType, Left:=, Top:=, Width:=, Height:=)

Arguments

The following arguments are required:

Type (Long) - The type of shape to be returned. Can be any MsoAutoShapeType constant.

Left (Single) - The position, measured in points, of the left edge of the AutoShape.

Top (Single) - The position, measured in points, of the top edge of the AutoShape.

Width (Single) - The width, measured in points, of the AutoShape.

Height (Single) - The height, measured in points, of the AutoShape.

The following argument is optional

Anchor - Range

Shapes.AddSmartArt

Inserts the specified SmartArt graphic into the active document.

Syntax : expression.AddSmartArt (Layout, Left, Top, Width, Height, Anchor)

Dim shpAddSmartArt As Shape
Set shpAddSmartArt = Selection.HeaderFooter.Shapes.AddSmartArt(Layout:=)

Arguments

The following argument is required

Layout (Office.SmartArtLayout) - A SmartArtLayout object that specifies the layout for the SmartArt graphic.

The following arguments are optional

Left (Long) - The distance, in points, from the left edge of the slide to the left edge of the SmartArt graphic.

Top (Long) - The distance, in points, from the top edge of the slide to the top edge of the SmartArt graphic.

Width (Long) - The width of the SmartArt graphic.

Height (Long) - The height of the SmartArt graphic.

Anchor (Range) - A Range object that represents the text to which the SmartArt graphic 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 SmartArt graphic is positioned relative to the top and left edges of the page.

Shapes.AddTextbox

Adds a text box to a drawing canvas.

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

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

Arguments

The following arguments are required:

Orientation (Office.MsoTextOrientation) - The orientation of the text. Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

Left (Single) - The position, measured in points, of the left edge of the text box.

Top (Single) - The position, measured in points, of the top edge of the text box.

Width (Single) - The width, measured in points, of the text box.

Height (Single) - The height, measured in points, of the text box.

The following argument is optional

Anchor - Range

Shapes.AddTextEffect

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

When you add WordArt to a document, the height and width of the WordArt are automatically set based on the size and amount of text you specify.

Syntax : expression.AddTextEffect (PresetTextEffect, Text, FontName, FontSize, FontBold, FontItalic, Left, Top, Anchor)

Sub NewCanvasTextEffect() 
 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:=100, Width:=150, _ 
 Height:=50) 
 
 'Add WordArt shape to the drawing canvas 
 shpCanvas.CanvasItems.AddTextEffect _ 
 PresetTextEffect:=msoTextEffect20, _ 
 Text:="Hello, World", FontName:="Tahoma", _ 
 FontSize:=15, FontBold:=msoTrue, _ 
 FontItalic:=msoFalse, _ 
 Left:=120, Top:=120 
End Sub

Arguments

The following arguments are required:

PresetTextEffect (Office.MsoPresetTextEffect) - A preset text effect. The values of the MsoPresetTextEffect constants correspond to the formats listed in the WordArt Gallery dialog box (numbered from left to right and from top to bottom).

Text (String) - The text in the WordArt.

FontName (String) - The name of the font used in the WordArt.

FontSize (Single) - The size (in points) of the font used in the WordArt.

FontBold (Office.MsoTriState) - MsoTrue to bold the WordArt font.

FontItalic (Office.MsoTriState) - MsoTrue to italicize the WordArt font.

Left (Single) - The position, measured in points, of the left edge of the WordArt shape relative to the left edge of the drawing canvas.

Top (Single) - The position, measured in points, of the top edge of the WordArt shape relative to the top edge of the drawing canvas.

The following argument is optional

Anchor - Range

Shapes.AddWebVideo

Adds a new web video to the document.

Syntax : expression.AddWebVideo (EmbedCode, VideoWidth, VideoHeight, PosterFrameImage, Url, Left, Top, Width, Height, Anchor)

Dim strEmbedCode As String: strEmbedCode = 
Dim iVideoWidth As Integer: iVideoWidth = 
Dim iVideoHeight As Integer: iVideoHeight =  
Dim shpAddWebVideo As Shape
Set shpAddWebVideo = Selection.HeaderFooter.Shapes.AddWebVideo(EmbedCode:=strEmbedCode, VideoWidth:=iVideoWidth, VideoHeight:=iVideoHeight)

Arguments

The following arguments are required:

EmbedCode (String) - The HTML code to embed.

VideoWidth (Integer) - An integer that represents the width of the web video in pixels.

VideoHeight (Integer) - An integer that represents the height of the web video in pixels.

The following arguments are optional

PosterFrameImage (String) - A string that points to the file to use as the poster frame for the web video.

Url (String) - A string that contains the URL to the web video.

Left (Long) - The position, measured in points, of the left edge of the poster frame from the edge of the document.

Top (Long) - The position, measured in points, of the top edge of the poster frame from the edge of the document.

Width (Long) - The width, measured in points, of the poster frame in the document.

Height (Long) - The height, measured in points, of the poster frame in the document.

Anchor (Range) - A Range object that represents the text to which the web video 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 video is positioned relative to the top and left edges of the page.