Setting a object to ctlBoundObjectFrame.Object crashes access

L

larryaxon

I have an Access report with a BoundObjectFrame that contains an MS word doc
from a table that has a column type of OLE Object.

It works fine until I try to get a Word.Application or Word.Document variable
assigned to it so I can do some simple manipulation (just some token
substitution).

The code looks like this:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ctlOLE As BoundObjectFrame
Dim myWordDoc As Word.Document
Dim o As Object
Set ctlOLE = WordDoc ' WordDoc is the name of the control
Set o = ctlOLE.Object ' it crashes here
' Set myWordDoc = o.Documents(1) ' or something like this: I just
want to do some Word stuff on the object
End Sub

Event though it looks to me like this conforms to the pattern in the code
samples in MS Access help, when I set anything (including the Object variable)
above, as well as a Variant, or whatever to the ctlOLE.Object, it crashes MS
Access and wants to send a report to Microsoft.

Yes, I have MS word in references.

This is MS Access 2003.

I also tried this with an Unbound frame with the same result.

I assume I must be doing something stupid, but I can't find what it is.

Anyone have experience with this?

Thanks.
 
R

Ralph

I dragged a Word document into the Report detail and it came in as an Unbound
Object Frame. I named it WordDoc then used:

dim wd as word.document
set wd=me.WordDoc.Object
With wd
'do something here
End With
 
L

larryaxon via AccessMonster.com

Excellent. This worked for me.
Thanks for your help.
Larry
I dragged a Word document into the Report detail and it came in as an Unbound
Object Frame. I named it WordDoc then used:

dim wd as word.document
set wd=me.WordDoc.Object
With wd
'do something here
End With
I have an Access report with a BoundObjectFrame that contains an MS word doc
from a table that has a column type of OLE Object.
[quoted text clipped - 31 lines]
 

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