> The problem occurs on this statement:
> ActiveDocument.MailMerge.Execute
> We use ODBCs to connect to our database, do a select
> statement, then pass the results
> along with the location of a .dbf file containing the
> result structure.
Unfortunately, I don't know of any way you can speed this
up. Usually, the problems we see come from the new, OlE DB
connections. Whatever might be going on behind the scenes
with your ODBC connection, I don't know of any way to
change what Word is doing. There aren't any settings or
anything one can change for how mail merge is executed.
However...
> Merging a single document could take as
> long as 30-60 seconds (one page document). The same
> document with the same data source on 97 or 2000 takes
> less than 5 seconds.
..this seems really a bit much. There are a few more
things I'd like you to test:
1. If run this merge by hand, rather than through code, do
you see the same behavior?
2. How about if you hold down CTRL when you start Word
(safe mode) and merge the existing main merge document?
3. And then to a new, blank document?
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
MattD - 08 Jul 2004 21:13 GMT
It looks like we have solved the problem, and may have
identified a bug with Microsoft Word 2002.
The query line in macros do not behave the same in Word
2002 as it did in Word 97 and 2000, and 2003.
The SQLStatement:=_ "SELECT * FROM dba.mailmergedata" _
will actually select all records from the table (taking
quite a bit of time), then select the correct record
when the activedocument.mailmerge.datasource.querystring
= "SELECT * FROM DBA.MailMergeData WHERE (N_OWNERID=185)
ORDER BY lastname, firstname"
******************
So if we change this:
ActiveDocument.MailMerge.OpenDataSource
Name:="C:\Program Files\product\Temp\\PatVar.dbf",
ConfirmConversions:= _ False, ReadOnly:=False,
LinkToSource:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _ WritePasswordTemplate:="",
Revert:=False, Format:=wdOpenFormatAuto, _
Connection:="DSN=datasn;UID=UID;PWD=pwd", SQLStatement:=
_ "SELECT * FROM dba.mailmergedata" _ , SQLStatement1:=
_ ""
With ActiveDocument.MailMerge
.DataSource.QueryString = "SELECT * FROM
DBA.MailMergeData WHERE
(N_OWNERID=185) ORDER BY lastname, firstname"
.Destination = wdSendToNewDocument
(etc)
To this:
ActiveDocument.MailMerge.OpenDataSource
Name:="C:\Program Files\product\Temp\\PatVar.dbf",
ConfirmConversions:= _ False, ReadOnly:=False,
LinkToSource:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _ WritePasswordTemplate:="",
Revert:=False, Format:=wdOpenFormatAuto, _
Connection:="DSN=datasn;UID=UID;PWD=pwd", SQLStatement:=
_ "SELECT * FROM DBA.MailMergeData WHERE (N_OWNERID=185)
ORDER BY lastname, firstname" _ , SQLStatement1:= _ ""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
(etc)
It doesn't do the additional selects from the entire
table. This change seems to also work fine in Word 97
and 2003 (I haven't tested in 2000 yet).
>-----Original Message-----
>> The problem occurs on this statement:
[quoted text clipped - 39 lines]
>
>.