Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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)
Syntax
'Declaration
Sub InsertFile ( _
FileName As String, _
ByRef Range As Object, _
ByRef ConfirmConversions As Object, _
ByRef Link As Object, _
ByRef Attachment As Object _
)
void InsertFile(
string FileName,
ref Object Range,
ref Object ConfirmConversions,
ref Object Link,
ref Object Attachment
)
Parameters
- FileName
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.
- Range
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).
- ConfirmConversions
Type: System.Object%
true to have Word prompt you to confirm conversion when inserting files in formats other than the Word Document format.
- Link
Type: System.Object%
true to insert the file by using a wdFieldIncludeText field.
- Attachment
Type: System.Object%
true to insert the file as an attachment to an e-mail message.
Remarks
Calling this method might delete the Bookmark control.
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.
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.doc at the root of the C directory.
This example is for a document-level customization.
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.doc", _
ConfirmConversions:=False, Link:=False, _
Attachment:=False)
End Sub
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.doc";
object ConfirmConversions = false;
object Link = false;
object Attachment = false;
bookmark1.InsertFile(FileName, ref missing, ref ConfirmConversions,
ref Link, ref Attachment);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.