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


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

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

void InsertFile(
	string FileName,
	ref object Range,
	ref object ConfirmConversions,
	ref object Link,
	ref object Attachment


Type: System.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.

Type: System.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).

Type: System.Object

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

Type: System.Object

true to insert the file by using a F:Microsoft.Office.Interop.Word.WdFieldType.wdFieldIncludeText field.

Type: System.Object

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

Calling this method might delete the Bookmark control.

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

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()
    Microsoft.Office.Tools.Word.Bookmark 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);
Return to top