Embeded Word document in Access

L

Leif

Failed to attract a response after 2 weeks under forms coding. Trying here...

I have Access 2003.

I'm trying to programmatically load a Word document into Access via OLE. I
have a table with a field called Reqmnts. Its data type is OLE Object. I
have a form with a bound Object Frame to the OLE Object. The field has an
"OLE Type Allowed" of Either.

If I use drag-and-drop of a Word document to the bound field on the form the
document is embeded with no problem. However, if I try to add the file
programmatically, I get an error 2793, "Position Profile Design (TEST) can't
perform the operation specified in the Action Property of the Visual Basic
procedure you're trying to run". This error occurs on the the setting of
Action.

My code is below. gOLEFileName is a global that is set via my modal form
ImportOLE.

Private Sub CmdAddWordDoc_Click()
On Error GoTo Err_cmdAddWordDoc_Click

' Make sure a level is selected prior to editting
'Make sure record is selected for editing
If IsNull(SRqmntID) = True Then
MsgBox "Specify Record", vbCritical, "Level must be selected for
adding a Word document"
GoTo cmdAddWordDoc_Click_Exit
Else
' Get the file name to load
DoCmd.OpenForm "ImportOLE", acNormal, , , , acDialog

If gOLEFileName <> "" Then
' Load the requirements
With [sfrm_Profile_Attributes_EditB]![Reqmnts]
.Class = "Word.Document"
.OLETypeAllowed = acOLEEmbedded
.SourceDoc = gOLEFileName
.Action = acOLECreateEmbed
.Size = acOLESizeZoom
End With
End If
gOLEFileName = ""
End If

cmdAddWordDoc_Click_Exit:
Exit Sub

Err_cmdAddWordDoc_Click:
MsgBox Error$
Resume cmdAddWordDoc_Click_Exit

End Sub


Thanks,
Leif
 
S

Stephen Lebans

Have you stepped through your code and verified that the gOLEFileName var
contains a valid/existing file name and path?
Do you have Norton Antivirus running? Try Disabling it.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top