Access Word Mailmerge Code 
Author Message
 Access Word Mailmerge Code

Can anyone let me know how I can speed up merging the contents of a database
query to a word template ( form letter ). The Access 2000 / 97 database VBA
code that I am using is shown below.
=================================
Dim objWord As Word.Document
Set objWord = GetObject("E:\...\Templates\Memo.doc", "Word.Document")
        objWord.Application.Visible = True
        objWord.MailMerge.OpenDataSource _
                Name:="E:\Work\Database\Registers\2CBSr1.mdb", _
                LinkToSource:=True, _
                Connection:="QUERY Corr out print memo query", _
                SQLStatement:="Select * FROM [Corr out print memo query]"

         With objWord.MailMerge
            .Destination = wdSendToNewDocument
            .Execute
        End With
=========================================
This works but takes a long time to open the word document and merge..
Thanks in advance for any suggestions.

Geeth



Sun, 19 Dec 2004 21:59:33 GMT  
 Access Word Mailmerge Code
here is part of the code from the method I use for a merge.   similar
to yours.   mind you, the department that uses this only merges a
couple of letters at a time, so I cannot comment on speed.

    DoCmd.TransferText acExportMerge, , "temp_table_holding_data",
"c:\tempfolder\txtOutput.doc"

'--- merge
    On Error Resume Next
    Set objWord = GetObject(, "Word.Application")
    '--- error 429 says that Word is not open yet
    If Err.Number = 429 Then
        Err.Number = 0
        Set objWord = CreateObject("Word.Application")
    End If

    objWord.Visible = True
    objWord.Documents.Open (strMF & "letter2.doc")
    objWord.ActiveDocument.mailmerge.opendatasource
("c:\tempfolder\txtOutput.doc")
    objWord.ActiveDocument.mailmerge.destination = 0
    objWord.ActiveDocument.mailmerge.Execute

On Wed, 3 Jul 2002 23:59:33 +1000, "Geeth Karunatillake"

Quote:

>Can anyone let me know how I can speed up merging the contents of a database
>query to a word template ( form letter ). The Access 2000 / 97 database VBA
>code that I am using is shown below.
>=================================
>Dim objWord As Word.Document
>Set objWord = GetObject("E:\...\Templates\Memo.doc", "Word.Document")
>        objWord.Application.Visible = True
>        objWord.MailMerge.OpenDataSource _
>                Name:="E:\Work\Database\Registers\2CBSr1.mdb", _
>                LinkToSource:=True, _
>                Connection:="QUERY Corr out print memo query", _
>                SQLStatement:="Select * FROM [Corr out print memo query]"

>         With objWord.MailMerge
>            .Destination = wdSendToNewDocument
>            .Execute
>        End With
>=========================================
>This works but takes a long time to open the word document and merge..
>Thanks in advance for any suggestions.

>Geeth

--------------------------
Richard "Manxman" Killey
visit my site for tips

http://www.comeandread.com/access



Sun, 19 Dec 2004 22:58:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Bar Codes in MailMerge / Insertion Point in MailMerge

2. VB to Word MailMerge Code Needed

3. MailMerge from Access 97 to Word 97, value lost

4. Checking Word Mailmerge status from Access VBA

5. problem mailmerging a Word 95 document from Access 95

6. Access -> Word Mailmerge questions

7. Two problems with mailmerge from Access 97 to Word 97

8. MailMerge to Word 7 from Access 7.0 runtime ?

9. Mailmerge Access To Word

10. Access 2000 to Word mailmerge-stability, performance (long)

11. MailMerge with Access + Word 2000 via ODBC

12. Mailmerge from vb using access table and word

 

 
Powered by phpBB® Forum Software