
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