Q: wait time for Word Mail Merge through access...

M

MarkD

Using Access 2000.

I created a sub that will do a mail merge from Access into
Word. I pass the document name and the query name. The
code written below is taken from Microsoft (Q209976).

For some reason, it takes several minutes to bring up the
Word document. The query is small (1 record) and running
the mail merge from Word itself is pretty much instant.
So, what gives?

Thanks!
-Mark


Sub CreateWordDocument(strDocName As String, Optional
strQueryName As String)
Dim objword As Word.Document
Set objword = GetObject(strDocName)

objword.Application.Visible = True
objword.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
Connection:="Query " & strQueryName,
'sqlstatement:="select * from " & strQueryName
'code fails whether above is commented or not.
objword.MailMerge.Execute
End Sub
 
S

ScottE

I'm not sure why your code is so slow, but here's a
slightly different way of doing it that works quickly on
my machine:

Dim wordApp As Object
Dim strDocName As String 'the doc to open

Set wordApp = CreateObject("Word.application")
wordApp.Documents.Open (strDocName)
wordApp.Application.Visible = True
**do your macro stuff here**
wordApp.Activate

Also, depending on your version of Word, you need to use
different "pointers" to the records. Office XP likes a
SQL string, pre-Office 2000 likes a row/column
designation, at least if you're grabbing from Excel.
Office 2000 I don't remember. One workaround is to give
it both, a la:

Connection:="r1c1:r2c75", SQLStatement:="SELECT * FROM
`mergeQuery$`"

See http://support.microsoft.com/default.aspx?
scid=http://support.microsoft.com:80/support/kb/articles/q2
85/3/32.asp&NoWebContent=1

for more on this.

I hope this helps!
 
M

MarkD

I'll have to try your version when I get back from turkey
day. Thanks and have a good Thanksgiving.

-Mark
 

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