AddPicture Method

Microsoft Word Visual Basic

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

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

expression    Required. An expression that returns a CanvasShapes object.

FileName   Required String. The path and file name of the picture.

LinkToFile   Optional Variant. 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   Optional Variant. True to save the linked picture with the document. The default value is False.

Left   Optional Variant. The position, measured in points, of the left edge of the new picture relative to the drawing canvas.

Top   Optional Variant. The position, measured in points, of the top edge of the new picture relative to the drawing canvas.

Width   Optional Variant. The width of the picture, in points.

Height   Optional Variant. The height of the picture, in points.

ShowAddPicture method as it applies to the InlineShapes object.

Adds a picture to a document. Returns a Shape object that represents the picture and adds it to the InlineShapes collection.

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

expression    Required. An expression that returns an InlineShapes object.

FileName   Required String. The path and file name of the picture.

LinkToFile   Optional Variant. 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   Optional Variant. True to save the linked picture with the document. The default value is False.

Range   Optional Variant. 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.

ShowAddPicture method as it applies to the Shapes object.

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

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

expression    Required. An expression that returns a Shapes object.

FileName   Required String. The path and file name of the picture.

LinkToFile   Optional Variant. 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   Optional Variant. True to save the linked picture with the document. The default value is False.

Left   Optional Variant. The position, measured in points, of the left edge of the new picture relative to the anchor.

Top   Optional Variant. The position, measured in points, of the top edge of the new picture relative to the anchor.

Width   Optional Variant. The width of the picture, in points.

Height   Optional Variant. The height of the picture, in points.

Anchor   Optional Variant. The range to which the picture 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, however, the anchor is placed automatically and the picture is positioned relative to the top and left edges of the page.

Example

ShowAs it applies to the CanvasShapes object.

This example adds a picture to a newly created drawing canvas in the active document.

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
				

ShowAs it applies to the Shapes object.

This example adds a picture to the active document. The picture is linked to the original file and is saved with the document.

Sub NewPicture()
    ActiveDocument.Shapes.AddPicture _
        FileName:="C:\Program Files\Microsoft Office\" _  
            & "Office\Bitmaps\Styles\stone.bmp", _
        LinkToFile:=True, SaveWithDocument:=True
End Sub