Compartilhar via


Bookmark.InsertFile(String, Object, Object, Object, Object) Method

Definition

Inserts all or part of the specified file into the Bookmark control.

public void InsertFile (string FileName, ref object Range, ref object ConfirmConversions, ref object Link, ref object Attachment);
abstract member InsertFile : string * obj * obj * obj * obj -> unit
Public Sub InsertFile (FileName As String, Optional ByRef Range As Object, Optional ByRef ConfirmConversions As Object, Optional ByRef Link As Object, Optional ByRef Attachment As Object)

Parameters

FileName
String

The path and file name of the file to be inserted. If you do not specify a path, Microsoft Office Word assumes the file is in the current folder.

Range
Object

If the specified file is a Word document, this parameter refers to a bookmark. If the file is another type (for example, a Microsoft Office Excel worksheet), this parameter refers to a named range or a cell range (for example, R1C1:R3C4).

ConfirmConversions
Object

true to have Word prompt you to confirm conversion when inserting files in formats other than the Word Document format.

Link
Object

true to insert the file by using a wdFieldIncludeText field.

Attachment
Object

true to insert the file as an attachment to an e-mail message.

Examples

The following code example adds a Bookmark control to the document and then inserts a file into the bookmark. This example requires that you have a document named Sales.docx at the root of the C directory.

This example is for a document-level customization.

private void BookmarkInsertFile()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
                
    string FileName = "C:\\Sales.docx";
    object ConfirmConversions = false;
    object Link = false;
    object Attachment = false;

    bookmark1.InsertFile(FileName, ref missing, ref ConfirmConversions,
        ref Link, ref Attachment);
}
Private Sub BookmarkInsertFile()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")

    Bookmark1.InsertFile(FileName:="C:\Sales.docx", _
        ConfirmConversions:=False, Link:=False, _
        Attachment:=False)

End Sub

Remarks

Calling this method might delete the Bookmark control.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to