Using Word in Access automation

D

Dave F

Hello -

I have been working on a project that calls for consolidating Word documents
embedded in an Access table. I have the hard part knocked (I think), but am
having a problem with getting Access to actually save the changes I'm
making.

On an Access form, I have a bound OLE frame container. Using the container,
I grab the Word document from record 1 and copy it to the clipboard. I then
open the Word document from record 2 and paste the contents of record 1 to
it. I then save the document, and update the record.

Pretty easy, surprisingly.

However, Access doesn't save the changes to the record. The changes I make
to the Word document of record 2 are not saved, and neither the
"before_update" or "after_update" events of the bound OLE container are
called (though the "updated" event of the bound OLE container is).

I've tried every verb on the acOLEActivate action to no avail (though I'm
not sure that has anything to do with the issue).

Any ideas? Thanks for your help!
Dave
 
J

John Nurick

Hi Dave,

As far as I know it's up to the parent application, not the
BoundObjectFrame whether or not the the embedded document is updated.
When I try it, the embedded document is updated when the code closes the
document object or quits the Word application object, e.g.
oWordDoc.Close True
or
oWordApp.Quit
 
D

Dave F

John -

That's what I thought too, but when I open the document in record 2 and
paste the results from record 1 into it, Word doesn't seem to save the
change, even though I have a WordDoc.Save and WordDoc.Quit in my code.

As a test, I've tried opening a document in a record via code, then just
making some changes manually and saving them with the same result. Maybe
there's something in Word automation I'm not doing.

Thanks for your help -
Dave
 
J

John Nurick

Word doesn't seem to save the
change, even though I have a WordDoc.Save and WordDoc.Quit in my code

The Word Document object doesn't have a Quit method, and the Word
Application object doesn't have a Save method, so whatever your code is
doing it's wrong.

This code worked as expected in my test database, though it's not what
I'd call bomb-proof:

Private Sub cmdDoStuff_Click()
Dim oWord As Word.Application
Dim oDoc As Word.Document

Me.fraDoc.Verb = acOLEVerbOpen
Me.fraDoc.Action = acOLEActivate

Set oWord = GetObject(, "Word.Application")
Set oDoc = oWord.Documents(1)

oDoc.Range.InsertAfter " I have just edited this document " & Now()

oDoc.Close True
oWord.Quit
End Sub
 

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