ACC2: How to Programmatically Embed or Link an Object in a FormID: Q114214
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article describes how to programmatically embed or link an object in
an OLE object field on a form using the object frame properties in
Microsoft Access version 2.0.
You can set the object frame Action property at run time to perform a
number of operations on an object frame. These operations include the
ability to embed and link objects in an object frame, as well as other
operations for programmatic access to OLE functionality.
There are other object frame properties that need to be set as
prerequisites to setting the Action property. The properties that need to
be set are determined by the type of OLE object you are working with and
the type of action, using the Action property, you want to perform.
NOTE: The constants for use by the Action property are defined in the
CONSTANT.TXT file, which is included with Microsoft Access. To use the
constants in your code, you must either declare them yourself or copy them
from the CONSTANT.TXT file and paste them into the Declarations section of
your Access Basic module.
' Specify what kind of object can appear in the field.
[Sales Totals].OLETypeAllowed = OLE_LINKED
' Specify the file to be linked.
[Sales Totals].SourceDoc = "C:\EXCEL\SALES.XLS"
' Specify the (optional) cell range to link to.
[Sales Totals].SourceItem = "R1C1:R5C5"
' Create the linked object.
[Sales Totals].Action = OLE_CREATE_LINK
' Specify what kind of object can appear in the field.
[Word Documents].OLETypeAllowed = OLE_EMBEDDED
' Specify the file containing the information to embed.
[Word Documents].SourceDoc = "C:\WINWORD\JONES.DOC"
' Create the embedded object.
[Word Documents].Action = OLE_CREATE_EMBED
' Specify what kind of object can appear in the field.
[Word Documents].Class = "Word.Document"
' Specify what kind of object can appear in the field.
[Word Documents].OLETypeAllowed = OLE_EMBEDDED
' Create the embedded object.
[Word Documents].Action = OLE_CREATE_EMBED
' Invoke Word for Windows to edit the empty embedded object.
[Word Documents].Action = OLE_ACTIVATE
Microsoft Access "Building Applications," version 2.0, Chapter 13,
"Communication With Other Applications," pages 295-297
For more information about the Action property, search for "Action," and
then "Action Property" using the Microsoft Access Help menu.
Additional query words: automation insert
Keywords : IntpOle
Version : 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 3, 1999