Add related procedures in class InlineShape (Word VBA)

This page presents procedures from class InlineShape related to the theme Add: InlineShapes.Add3DModel, InlineShapes.AddChart2, InlineShapes.AddHorizontalLine, InlineShapes.AddHorizontalLineStandard, InlineShapes.AddOLEControl, InlineShapes.AddOLEObject, InlineShapes.AddPicture, InlineShapes.AddPictureBullet, InlineShapes.AddSmartArt and InlineShapes.AddWebVideo

InlineShapes.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, Range)

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.

Range

InlineShapes.AddChart2

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

Syntax : expression.AddChart2 (Style, Type, Range, NewLayout)

Dim iseAddChart2 As InlineShape
Set iseAddChart2 = ActiveDocument.Range.InlineShapes.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

Range (Range) - The range where the chart will be placed in the text. The chart replaces the range, unless the range is collapsed. If this argument is omitted, the chart is placed automatically.

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).

InlineShapes.AddHorizontalLine

Adds a horizontal line based on an image file to the current document.

To add a horizontal line that isn't based on an existing image file, use the AddHorizontalLineStandard method.

Syntax : expression.AddHorizontalLine (FileName, Range)

Selection.InlineShapes.AddHorizontalLine _ 
 "C:\Art files\ArtsyRule.gif"

Arguments

The following argument is required

FileName (String) - The file name of the image you want to use for the horizontal line.

The following argument is optional

Range (Range) - The range above which Microsoft Word places the horizontal line. If this argument is omitted, Word places the horizontal line above the current selection.

InlineShapes.AddHorizontalLineStandard

Adds a horizontal line to the current document.

To add a horizontal line based on an existing image file, use the AddHorizontalLine method.

Syntax : expression.AddHorizontalLineStandard (Range)

Range: The range above which Microsoft Word places the horizontal line. If this argument is omitted, Word places the horizontal line above the current selection.

ActiveDocument.Paragraphs(5).Range _ 
 .InlineShapes.AddHorizontalLineStandard

InlineShapes.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, Range)

Dim iseAddOLEControl As InlineShape
Set iseAddOLEControl = ActiveDocument.Range.InlineShapes.AddOLEControl()

Arguments

The following arguments are optional

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

Range (Range) - The range where the ActiveX control will be placed in the text. The ActiveX control replaces the range, if the range isn't collapsed. If this argument is omitted, the Active X control is placed automatically.

InlineShapes.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, Range)

ActiveDocument.InlineShapes.AddOLEObject _ 
 ClassType:="Excel.Sheet", DisplayAsIcon:=False, _ 
 Range:=ActiveDocument.Paragraphs(2).Range

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 (Insert menu, Object 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.

Range (Range) - The range where the OLE object will be placed in the text. The OLE object replaces the range, unless the range is collapsed. If this argument is omitted, the object is placed automatically.

InlineShapes.AddPicture

Adds a picture to a document. Returns an InlineShape object that represents the picture.

Syntax : expression.AddPicture (FileName, LinkToFile, SaveWithDocument, Range)

Dim strFileName As String: strFileName =  
Dim iseAddPicture As InlineShape
Set iseAddPicture = ActiveDocument.Range.InlineShapes.AddPicture(FileName:=strFileName)

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.

Range (Range) - The location where the picture will be placed in the text. If the range isn't collapsed, the picture replaces the range; otherwise, the picture is inserted. If this argument is omitted, the picture is placed automatically.

InlineShapes.AddPictureBullet

Adds a picture bullet based on an image file to the current document. Returns an InlineShape object.

Syntax : expression.AddPictureBullet (FileName, Range)

Selection.InlineShapes.AddPictureBullet _ 
 "C:\Art files\RedBullet.gif"

Arguments

The following argument is required

FileName (String) - The file name of the image you want to use for the picture bullet.

The following argument is optional

Range (Range) - The range to which Microsoft Word adds the picture bullet. Word adds the picture bullet to each paragraph in the range. If this argument is omitted, Word adds the picture bullet to each paragraph in the current selection.

InlineShapes.AddSmartArt

Inserts a SmartArt graphic as an inline shape into the active document.

Syntax : expression.AddSmartArt (Layout, Range)

Dim iseAddSmartArt As InlineShape
Set iseAddSmartArt = ActiveDocument.Range.InlineShapes.AddSmartArt(Layout:=)

Arguments

The following argument is required

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

The following argument is optional

Range (Range) - Specifies the text to which the SmartArt graphic is bound. If Range is specified, the SmartArt graphic is positioned at the beginning of the first paragraph in the range. If this argument is omitted, the range is selected automatically, and the SmartArt graphic is positioned relative to the top and left edges of the page.

InlineShapes.AddWebVideo

Adds a new web video to the document.

Syntax : expression.AddWebVideo (EmbedCode, VideoWidth, VideoHeight, PosterFrameImage, Url, Range)

Dim strEmbedCode As String: strEmbedCode = 
Dim iVideoWidth As Integer: iVideoWidth = 
Dim iVideoHeight As Integer: iVideoHeight =  
Dim iseAddWebVideo As InlineShape
Set iseAddWebVideo = ActiveDocument.Range.InlineShapes.AddWebVideo(EmbedCode:=strEmbedCode, VideoWidth:=iVideoWidth, VideoHeight:=iVideoHeight)

Arguments

The following arguments are required:

EmbedCode (String) - The embed code for the video.

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) - The URL to the video.

Range (Range) - The range at which to insert the web video. If Range is omitted, the current selection is used.