Add related procedures in class Shape (PowerPoint VBA)

This page presents procedures from class Shape related to the theme Add: Shapes.Add3DModel, Shapes.AddCallout, Shapes.AddChart2, Shapes.AddConnector, Shapes.AddCurve, Shapes.AddInkShapeFromXML, Shapes.AddLabel, Shapes.AddLine, Shapes.AddMediaObject2, Shapes.AddMediaObjectFromEmbedTag, Shapes.AddOLEObject, Shapes.AddPicture, Shapes.AddPicture2, Shapes.AddPlaceholder, Shapes.AddPolyline, Shapes.AddShape, Shapes.AddSmartArt, Shapes.AddTable, Shapes.AddTextbox, Shapes.AddTextEffect and Shapes.AddTitle

Shapes.Add3DModel

Creates a Model3DFormat object from an existing file. Returns a Shape object that represents the new 3D model.

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

Dim strFileName As String: strFileName = 
Dim shpAdd3DModel As Shape
Set shpAdd3DModel = ActiveWindow.Selection.SlideRange(1).Shapes.Add3DModel(FileName:=strFileName, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=, Top:=)

Arguments

The following arguments are required:

FileName (String) - The file from which the 3D model object is to be created.

LinkToFile (Office.MsoTriState) - Determines whether the 3D model will be linked to the file from which it was created.

SaveWithDocument (Office.MsoTriState) - Determines whether the linked 3D model will be saved with the document into which it is inserted. This argument must be msoTrue if LinkToFile is msoFalse.

Left (Single) - The position, measured in points, of the left edge of the 3D model relative to the left edge of the slide.

Top (Single) - The position, measured in points, of the top edge of the 3D model relative to the top edge of the slide.

The following arguments are optional

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

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

Shapes.AddCallout

Creates a borderless line callout. Returns a Shape object that represents the new callout.

You can insert a greater variety of callouts by using the AddShape method.

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

Dim shpAddCallout As Shape
Set shpAddCallout = ActiveWindow.Selection.SlideRange(1).Shapes.AddCallout(Type:=msoCalloutMixed, Left:=, Top:=, Width:=, Height:=)

Arguments

The following arguments are required:

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

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

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

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

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

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, NewLayout)

Dim shpAddChart2 As Shape
Set shpAddChart2 = ActivePresentation.SlideMaster.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 (Single) - The position, in points, of the left edge of the chart, relative to the anchor.

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

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

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

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

Shapes.AddConnector

Creates a connector. Returns a Shape object that represents the new connector. When a connector is added, it is not connected to anything. Use the BeginConnect and EndConnect methods to attach the beginning and end of a connector to other shapes in the document.

When you attach a connector to a shape, the size and position of the connector are automatically adjusted, if necessary. Therefore, if you are going to attach a connector to other shapes, the position and dimensions you specify when adding the connector are irrelevant.

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

Dim shpAddConnector As Shape
Set shpAddConnector = ActiveWindow.Selection.SlideRange(1).Shapes.AddConnector(Type:=msoConnectorTypeMixed, BeginX:=, BeginY:=, EndX:=, EndY:=)

Arguments

The following arguments are required:

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

BeginX (Single) - The horizontal position, measured in points, of the connector's starting point relative to the left edge of the slide.

BeginY (Single) - The vertical position, measured in points, of the connector's starting point relative to the top edge of the slide.

EndX (Single) - The horizontal position, measured in points, of the connector's ending point relative to the left edge of the slide.

EndY (Single) - The vertical position, measured in points, of the connector's ending point relative to the top edge of the slide.

Shapes.AddCurve

Creates a Bézier curve. Returns a Shape object that represents the new curve.

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.

Dim lngSafeArrayOfPoints() As Long: lngSafeArrayOfPoints() = 
Dim shpAddCurve As Shape
Set shpAddCurve = ActiveWindow.Selection.SlideRange(1).Shapes.AddCurve(SafeArrayOfPoints:=lngSafeArrayOfPoints())

Shapes.AddInkShapeFromXML

Creates an ink shape. Returns a Shape object that represents the new ink shape.

Syntax : expression.AddInkShapeFromXML (InkXML, Left, Top, Width, Height)

Dim strInkXML As String: strInkXML = 
Dim shpAddInkShapeFromXML As Shape
Set shpAddInkShapeFromXML = ActivePresentation.SlideMaster.Shapes.AddInkShapeFromXML(InkXML:=strInkXML, Left:=, Top:=)

Arguments

The following arguments are required:

InkXML - String

Left (Single) - The position, measured in points, of the left edge of the ink shape relative to the left edge of the slide.

Top (Single) - The position, measured in points, of the top edge of the ink shape relative to the top edge of the slide.

The following arguments are optional

Width (Single) - The width of the ink shape, measured in points. If this parameter is not specified, the width is calculated based off of the InkActionML.

Height (Single) - The height of the ink shape, measured in points. If this parameter is not specified, the hight is calculated based off of the InkActionML.

Shapes.AddLabel

Creates a label. Returns a Shape object that represents the new label.

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

Dim shpAddLabel As Shape
Set shpAddLabel = ActiveWindow.Selection.SlideRange(1).Shapes.AddLabel(Orientation:=msoTextOrientationMixed, Left:=, Top:=, Width:=, Height:=)

Arguments

The following arguments are required:

Orientation (Office.MsoTextOrientation) - The text orientation. 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 label relative to the left edge of the slide.

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

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

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

Shapes.AddLine

Creates a line. Returns a Shape object that represents the new line.

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

Dim shpAddLine As Shape
Set shpAddLine = ActiveWindow.Selection.SlideRange(1).Shapes.AddLine(BeginX:=, BeginY:=, EndX:=, EndY:=)

Arguments

The following arguments are required:

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

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

EndX (Single) - The horizontal position, measured in points, of the line's ending point relative to the left edge of the slide.

EndY (Single) - The vertical position, measured in points, of the line's ending point relative to the top edge of the slide.

Shapes.AddMediaObject2

Replaces deprecated Shapes.AddMediaObject method (PowerPoint). Adds a new media object.

The default value varies depending whether the new media is an audio or video file, and on file size. If both LinkToFile and SaveWithDocument are False, this method returns an error. At least one must be True. Note that the object model allows an object to be both linked and embedded, which is not allowed through the user interface (UI).

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

Dim strFileName As String: strFileName = 
Dim shpAddMediaObject2 As Shape
Set shpAddMediaObject2 = ActivePresentation.SlideMaster.Shapes.AddMediaObject2(FileName:=strFileName)

Arguments

The following argument is required

FileName (String) - The name of the file to be added.

The following arguments are optional

LinkToFile (Office.MsoTriState) - Indicates whether to link to the file.

SaveWithDocument (Office.MsoTriState) - Indicates whether to save the media with the document.

Left (Single) - The distance, in points, from the left edge of the slide to the left edge of the media object.

Top (Single) - The distance, in points, from the top edge of the slide to the top edge of the media object.

Width (Single) - The width, in points, of the media object. Default value is -1.

Height (Single) - The height, in points, of the media object. Default value is -1.

Shapes.AddMediaObjectFromEmbedTag

Adds a media object from an embedded tag to a Shapes object.

Syntax : expression.AddMediaObjectFromEmbedTag (EmbedTag, Left, Top, Width, Height)

Dim strEmbedTag As String: strEmbedTag = 
Dim shpAddMediaObjectFromEmbedTag As Shape
Set shpAddMediaObjectFromEmbedTag = ActivePresentation.SlideMaster.Shapes.AddMediaObjectFromEmbedTag(EmbedTag:=strEmbedTag)

Arguments

The following argument is required

EmbedTag (String) - The embed tag.

The following arguments are optional

Left (Single) - The distance, in points, from the left edge of the slide to the left edge of the media object.

Top (Single) - The distance, in points, from the top edge of the slide to the top edge of the media object.

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

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

Shapes.AddOLEObject

Creates an OLE object. Returns a Shape object that represents the new OLE object.

Syntax : expression.AddOLEObject (Left, Top, Width, Height, ClassName, FileName, DisplayAsIcon, IconFileName, IconIndex, IconLabel, Link)

Dim shpAddOLEObject As Shape
Set shpAddOLEObject = ActiveWindow.Selection.SlideRange(1).Shapes.AddOLEObject()

Arguments

The following arguments are optional

Left (Single) - The position (in points) of the upper-left corner of the new object relative to the upper-left corner of the slide. The default value is 0 (zero).

Top (Single) - The position (in points) of the upper-left corner of the new object relative to the upper-left corner of the slide. The default value is 0 (zero).

Width (Single) - The initial width of the OLE object, in points.

Height (Single) - The initial height of the OLE object, in points.

ClassName (String) - The OLE long class name or the ProgID for the object that's to be created. You must specify either the ClassName or FileName argument for the object, but not both.

FileName (String) - The file from which the object is to be created. If the path isn't specified, the current working folder is used. You must specify either the ClassName or FileName argument for the object, but not both.

DisplayAsIcon (Office.MsoTriState) - Determines whether the OLE object will be displayed as an icon.

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

IconIndex (Long) - The index of the icon within IconFileName. 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.

Link (Office.MsoTriState) - Determines whether the OLE object will be linked to the file from which it was created. If you specified a value for ClassName, this argument must be msoFalse.

Shapes.AddPicture

Creates a picture from an existing file. Returns a Shape object that represents the new picture.

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

Dim strFileName As String: strFileName = 
Dim shpAddPicture As Shape
Set shpAddPicture = ActiveWindow.Selection.SlideRange(1).Shapes.AddPicture(FileName:=strFileName, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=, Top:=)

Arguments

The following arguments are required:

FileName (String) - The file from which the OLE object is to be created.

LinkToFile (Office.MsoTriState) - Determines whether the picture will be linked to the file from which it was created.

SaveWithDocument (Office.MsoTriState) - Determines whether the linked picture will be saved with the document into which it is inserted. This argument must be msoTrue if LinkToFile is msoFalse.

Left (Single) - The position, measured in points, of the left edge of the picture relative to the left edge of the slide.

Top (Single) - The position, measured in points, of the top edge of the picture relative to the top edge of the slide.

The following arguments are optional

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

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

Shapes.AddPicture2

Creates a picture from an existing file. Returns a Shape object that represents the new picture.

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

Dim strFileName As String: strFileName = 
Dim shpAddPicture2 As Shape
Set shpAddPicture2 = ActivePresentation.SlideMaster.Shapes.AddPicture2(FileName:=strFileName, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=, Top:=)

Arguments

The following arguments are required:

FileName (String) - The file from which the OLE object is to be created.

LinkToFile (Office.MsoTriState) - Determines whether the picture will be linked to the file from which it was created.

SaveWithDocument (Office.MsoTriState) - Determines whether the linked picture will be saved with the document into which it is inserted. This argument must be msoTrue if LinkToFile is msoFalse.

Left (Single) - The position, measured in points, of the left edge of the picture relative to the left edge of the slide.

Top (Single) - The position, measured in points, of the top edge of the picture relative to the top edge of the slide.

The following arguments are optional

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

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

compress (Office.MsoPictureCompress) - Determines whether the picture should be compressed when inserted.

Shapes.AddPlaceholder

Restores a previously deleted placeholder on a slide. Returns a Shape object that represents the restored placeholder.

If more than one placeholder of a specified type has been deleted from the slide, the AddPlaceholder method will add them back to the slide, one by one, starting with the placeholder that has the lowest original index number.

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

Dim shpAddPlaceholder As Shape
Set shpAddPlaceholder = ActiveWindow.Selection.SlideRange(1).Shapes.AddPlaceholder(Type:=ppPlaceholderBitmap)

Arguments

The following argument is required

Type (PpPlaceholderType) - The type of placeholder. Placeholders of type ppPlaceholderVerticalBody or ppPlaceholderVerticalTitle are found only on slides of layout type ppLayoutVerticalText, ppLayoutClipArtAndVerticalText, ppLayoutVerticalTitleAndText, or ppLayoutVerticalTitleAndTextOverChart. You cannot create slides with any of these layouts from the user interface; you must create them programmatically by using the Add method or by setting the Layout property of an existing slide.

Here you can find possible values for PpPlaceholderType.

The following arguments are optional

Left (Single) - The position (in points) of the upper-left corner of the placeholder relative to the upper-left corner of the document.

Top (Single) - The position (in points) of the upper-left corner of the placeholder relative to the upper-left corner of the document.

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

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

Shapes.AddPolyline

Creates an open polyline or a closed polygon drawing. Returns a Shape object that represents the new polyline or 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.

Dim lngSafeArrayOfPoints() As Long: lngSafeArrayOfPoints() = 
Dim shpAddPolyline As Shape
Set shpAddPolyline = ActiveWindow.Selection.SlideRange(1).Shapes.AddPolyline(SafeArrayOfPoints:=lngSafeArrayOfPoints())

Shapes.AddShape

Creates an AutoShape. Returns a Shape object that represents the new AutoShape.

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

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

Dim shpAddShape As Shape
Set shpAddShape = ActiveWindow.Selection.SlideRange(1).Shapes.AddShape(Type:=msoShapeMixed, Left:=, Top:=, Width:=, Height:=)

Arguments

The following arguments are required:

Type (Office.MsoAutoShapeType) - Specifies the type of AutoShape to create.

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

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

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

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

Shapes.AddSmartArt

Adds a SmartArt diagram to the Shapes object.

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

Dim shpAddSmartArt As Shape
Set shpAddSmartArt = ActivePresentation.SlideMaster.Shapes.AddSmartArt(Layout:=)

Arguments

The following argument is required

Layout (Office.SmartArtLayout) - The SmartArt diagram to add.

The following arguments are optional

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

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

Width (Single) - The width of the SmartArt diagram.

Height (Single) - The height of the SmartArt diagram.

Shapes.AddTable

Adds a table shape to a slide.

Syntax : expression.AddTable (NumRows, NumColumns, Left, Top, Width, Height)

Dim lngNumRows As Long: lngNumRows = 
Dim lngNumColumns As Long: lngNumColumns = 
Dim shpAddTable As Shape
Set shpAddTable = ActiveWindow.Selection.SlideRange(1).Shapes.AddTable(NumRows:=lngNumRows, NumColumns:=lngNumColumns)

Arguments

The following arguments are required:

NumRows (Long) - The number of rows in the table.

NumColumns (Long) - The number of columns in the table.

The following arguments are optional

Left (Single) - The distance (in points) from the left edge of the slide to the left edge of the table.

Top (Single) - The distance (in points) from the top edge of the slide to the top edge of the table.

Width (Single) - The width (in points) of the new table.

Height (Single) - The height (in points) of the new table.

Shapes.AddTextbox

Creates a text box. Returns a Shape object that represents the new text box.

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

Dim shpAddTextbox As Shape
Set shpAddTextbox = ActiveWindow.Selection.SlideRange(1).Shapes.AddTextbox(Orientation:=msoTextOrientationMixed, Left:=, Top:=, Width:=, Height:=)

Arguments

The following arguments are required:

Orientation (Office.MsoTextOrientation) - The text orientation. 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 relative to the left edge of the slide.

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

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

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

Shapes.AddTextEffect

Creates a WordArt object. Returns a Shape object that represents the new WordArt object.

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)

Dim strText As String: strText = 
Dim strFontName As String: strFontName = 
Dim shpAddTextEffect As Shape
Set shpAddTextEffect = ActiveWindow.Selection.SlideRange(1).Shapes.AddTextEffect(PresetTextEffect:=msoTextEffectMixed, Text:=strText, FontName:=strFontName, FontSize:=, FontBold:=msoTrue, FontItalic:=msoTrue, Left:=, Top:=)

Arguments

The following arguments are required:

PresetTextEffect (Office.MsoPresetTextEffect) - The preset text effect.

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) - Determines whether the font used in the WordArt is set to bold.

FontItalic (Office.MsoTriState) - Determines whether the font used in the WordArt is set to italic.

Left (Single) - The position, measured in points, of the left edge of the WordArt's bounding box relative to the left edge of the slide.

Top (Single) - The position, measured in points, of the top edge of the WordArt's bounding box relative to the top edge of the slide.

Shapes.AddTitle

Restores a previously deleted title placeholder to a slide. Returns a Shape object that represents the restored title.

This method will cause an error if you haven't previously deleted the title placeholder from the specified slide. Use the HasTitle property to determine whether the title placeholder has been deleted.

Dim shpAddTitle As Shape
Set shpAddTitle = ActiveWindow.Selection.SlideRange(1).Shapes.AddTitle()