Access97/Word97 MailMerge 
Author Message
 Access97/Word97 MailMerge

I'm trying to perform a Word97 MailMerge from Access97 with OLE Automation.
When first run, it works perfectly:
1. opening and viewing Word
2. creating a new MailMerge main document
3. selecting data source (the Access database)
4. inserting merge fields from the Access table
5. performing the actual MailMerge

But, after closing Word, running the same procedure a second time stops in
step 4 on inserting the first Access field into the document. The err msg
"Runtime error '-2147023169 (800706bf)': Automation error" appears. If
having Word running after the first execution of the procedure, the err msg
"Runtime error '5825': Object has been deleted." appears. Maybe this err
msg comes of some temporary storage space still in memory, or something...
The line on which the above appears is:
   objWord.ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range,
Name:="strFname"
which is "borrowed" from a Word macro.

I have tried several different ways of dimensioning and setting the Word
object variable:
   Dim objWord as Object
   Set objWord = CreateObject("Word.Application")
- or -
   Dim objWord as Word.Application
   Set objWord = CreateObject("Word.Application")
- or -
   Dim objWord as New Word.Application
but the problem persists.

I have tried using:
   Set objWord = Nothing
in the end of the sub to make sure the variable is "cleared".

I have also tried to check if the Word object is valid by using:
   If Not objWord.IsObjectValid(objWord) Then... etc
but this doesn't indicate at any point that the object is invalid.

Another thing I have tested is to MailMerge through ODBC instead of DDE
using a pre-defined DSN. This generates exactly the same behaviour as the
DDE version.
Initially I used the same Access database as the code resided in, to
perform MailMerge on. But the err msg appears even when using another
database as data source.

Now, do anyone know how to solve this? Is it a 'bug' or one of the least
wanted features? Please reply with suggestions. It will be greatly
appreciated.

/Lars



Sun, 08 Aug 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Access97 and Word97 (MailMerge)

2. OLE Mailmerge Automation Error 5987 to Word97

3. (Q) Word97 MailMerge Data sources

4. accessing word97 MailMerge fields in HEADER

5. mailmerge with word97,2000,xp using vb.net,vb6

6. mailmerge with word97,2000,xp using vb6,vb.net

7. mailmerge with secure database (Word97 vb5)

8. VB6 - Word97. Mailmerge Automation

9. Mailmerge with secure access database (word97 vb5)

10. Mailmerge with word97 or word 2000

11. How can I do MS WORD97 MailMerge Funtion in VB6

12. Closing Word97 from Access97

 

 
Powered by phpBB® Forum Software