ACC2: How to Open/Edit MS Word Document in Bound Object FrameID: Q132240
|
This article demonstrates sample Access Basic code that you can set for the
OnDblClick property event procedure of a bound OLE object control so that
you can open/edit a previously embedded OLE object. If no object exists, a
new Microsoft Word document is embedded.
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information about Access Basic, please
refer to the "Building Applications" manual.
To create the sample Access Basic code so that you can open/edit a
previously embedded OLE object, follow these steps.
CAUTION: Following the steps in this example will modify the sample
database NWIND.MDB. You may want to back up the NWIND.MDB file, or perform
these steps on a copy of the NWIND database.
Sub Photo_DblClick (Cancel as Integer)
On Error GoTo NoOLEObject
Me![Photo].Verb = VERB_OPEN
Me![Photo].Action = OLE_ACTIVATE
Exit Sub
NoOLEObject:
If Err = 2684 Then
Me![Photo].OLETypeAllowed = OLE_EMBEDDED
Me![Photo].SourceDoc = "C:\TEST.DOC"
Me![Photo].Action = OLE_CREATE_EMBED
Resume
Else
MsgBox "Error - " & Str(Err) & " : " & Error
End If
Exit Sub
End Sub
Global Const VERB_OPEN = -2
Global Const OLE_ACTIVATE = 7
Global Const OLE_EMBEDDED = 1
Global Const OLE_CREATE_EMBED = 0
-Or-
Microsoft Access "Building Applications," version 2.0, Chapter 13,
"Creating an Embedded OLE Automation Object from a File," page 297
For more information about OLE Automation and the Verb property, search for
"Verb" using the Microsoft Access Help index.
For more information about OLE Automation, please see the following
articles in the Microsoft Knowledge Base:
Q123859 ACC: Sample OLE Automation for Microsoft Word and Microsoft
Excel
Q124862 ACC: Sending the Current Record to Word with OLE Automation
Additional query words: automate
Keywords : kbinterop IntpOlea
Version : 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 26, 1999