Syntax
InsertObject [.IconNumber = number] [, .FileName = text] [, .Link = number] [, .DisplayIcon = number] [, .Tab = number] [, .Class = text] [, .IconFilename = number] [, .Caption = text]
Remarks
Starts an object linking and embedding (OLE) application in which the user creates an object, or immediately creates an embedded object using a specified file. In either case, InsertObject inserts an EMBED field at the insertion point.
Argument | Explanation |
.IconNumber | If .DisplayIcon is set to 1, a number corresponding to the icon you want to use in the program file specified by .IconFilename. Icons appear in the Change Icon dialog box (Object command, Insert menu): 0 (zero) corresponds to the first icon, 1 to the second icon, and so on. If omitted, the first (default) icon is used. Note that on the Macintosh, icons for embedded objects cannot be changed and this argument is ignored. |
.FileName | The path and filename of the file you want to store as an embedded object in the active document. If you specify .Filename, you must set .Tab to 1 and specify .Class. For an example of inserting an existing file as an object, see the second example in this entry. |
.Link | If 1, links the embedded object to the file specified by .FileName. When the file changes, Word updates the embedded object. |
.DisplayIcon | Specifies whether or not to display a link as an icon: 0 (zero) or omitted Link is not displayed as an icon. 1 Link is displayed as an icon. |
.Tab | Specifies which tab to select when you display the Object dialog box with a Dialog or Dialog() instruction. 0 (zero) Create New tab 1 Create From File tab |
.Class | The class name of a new object to insert. To look up class names, insert an object in a document and view the field codes; the class name of the object follows the word "EMBED." |
.IconFilename | If .DisplayIcon is set to 1, the path and filename of the program file in which the icon to be displayed is stored. Note that on the Macintosh, icons for embedded objects cannot be changed and this argument is ignored. |
.Caption | If .DisplayIcon is set to 1, the caption of the icon to be displayed; if omitted, Word inserts the name of the object. |
Examples
This Windows example starts Paintbrush®. When the user chooses Exit & Return from the File menu, Word inserts the following field at the insertion point: {EMBED PBrush \ * MERGEFORMAT}.
InsertObject .Class = "PBrush"
The following Windows example inserts an embedded object that is linked to the file FLOCK.BMP:
InsertObject .FileName = "C:\WIN31\FLOCK.BMP", .Link = 1, \
.Tab = 1, .Class = "Pbrush"
The following Macintosh example inserts an embedded object that is linked to the file APRIL SALES:
InsertObject .FileName = "HD1:MICROSOFT WORD:CHARTS:APRIL SALES", \
.Link = 1, .Tab = 1, .Class = "MSGraph"
See Also
ActivateObject, EditObject, InsertChart, InsertDrawing, InsertExcelTable