Syntax
InsertFile .Name = text [, .Range = text] [, .ConfirmConversions = number] [, .Link = number]
Remarks
Inserts all or part of the specified file at the insertion point.
Argument | Explanation |
.Name | The path and filename of the file to insert. If the path is not specified, the current folder is assumed. |
.Range | If the file specified by .Name is a Word document, .Range is a bookmark. If the file is another type (for example, a Microsoft Excel worksheet), .Range refers to a named range or cell range (for example, R1C1:R3C4). If Word cannot recognize .Range, an error occurs. |
.ConfirmConversions | Specifies whether Word displays the Convert File dialog box when inserting files in formats other than Word Document format. |
.Link | If 1, inserts an INCLUDETEXT field instead of the contents of the file itself. |
Examples
This example inserts the contents of PRICES.DOC into the active document. On the Macintosh, substitute a path and filename such as HD:PRICES:PRICE LIST.
InsertFile .Name = "C:\PRICES\PRICES.DOC"
The following example inserts the portion of PRICES.DOC marked with the bookmark "sportscars" into the active document:
InsertFile .Name = "PRICES.DOC", .Range = "sportscars"
The following Windows example creates a new document and then inserts one INCLUDETEXT field for each file in the folder C:\TMP with the filename extension .TXT:
FileNewDefault ChDir "C:\TMP" name$ = Files$("*.TXT") While name$ <> "" InsertFile name$, .Link = 1, .ConfirmConversions = 0 InsertPara name$ = Files$() Wend
To change the previous example for the Macintosh, substitute ChDir "HD:TEMP FILES" and name$ = Files$(MacID$("TEXT")) for the second and third instructions, respectively.
See Also
InsertDatabase, InsertField