Dynamic Object Frame (1 Viewer)

DocNice

Registered User.
Local time
Yesterday, 22:05
Joined
Oct 6, 2004
Messages
76
I would like to open a form that shows a word document (or preferably a thumbnail of a word document) in an object frame.

The document(s) displayed would need to change based on information on the form, or sent to the form when opened. I would strongly prefer this to be an unbound frame since storing tens of thousands of Word documents in the database would be a major hassle.

I've been playing around with the following code trying to get off on the right foot. It creates a new form based on information found in a text box on the current form, but it throws an error on the acOLECreateLink line saying that the unbound object frame on the new form doesn't contain and OLE object.

Any suggestions? Thanks!


Dim varSource As String
Dim OLE1 As Object
Dim control1 As Control
Dim frm As Form

varsource = [file path]
Set frm = CreateForm
Set OLE1 = CreateControl(frm.Name, acObjectFrame, , , , 500, 500)

OLE1.Class = "Word.Document" ' Set class name.
' Specify type of object.
OLE1.OLETypeAllowed = acOLELinked
' Specify source file.
OLE1.SourceDoc = varSource
' Create linked object.
OLE1.Action = acOLECreateLink

DoCmd.Restore
 

DocNice

Registered User.
Local time
Yesterday, 22:05
Joined
Oct 6, 2004
Messages
76
I found something that works well. I have to massage it a bit more for my purposes, but here is the basic code.

First you need to create a form that is editable and not locked, with an unbound object frame that is set to a new bitmap object. Name the frame wrdFrame, or some other relevant reference.

Then use this code:
' Specify OLE Class, Type, SourceDoc and other properties.
With wrdFrame
.Class = "Word.Document"
.OLETypeAllowed = acOLELinked
.SourceDoc = [file path]
.Action = acOLECreateLink
End With
 

Users who are viewing this thread

Top Bottom