VBA:Don't Show SQL Command Box When Opening Mail Merge in Ms Word

Susanto3311
3StarLounger
Posts: 240
Joined: 17 Feb 2022, 05:16

VBA:Don't Show SQL Command Box When Opening Mail Merge in Ms Word

Post by Susanto3311 »

hi all..

i want to make mail merge with excel as source database and ms word as main document
the normally when before running mail merge will be show dialog box "Opening this document will......." SELECT * FROM C:\....."
how to make mail merge when first running mail merge automatically connected with database/source without showing dialog SQL.....
please, give me easy step for this case. i have around in google for searching the macro/vba, but i don't know how to use it.

for detail information for my actual problem:
1. all my files (data excel & word ), save/storage in path C:\myjob --'folder "myjob"
2. main document in ms word format save with name file "docuprime"
3. excel file as database (source data) with name file "mysource" with active sheet name is "compile"

note:
when creating mail merge, i use connector option "Ms Excel via DDE....." --"i want excel sheet always keep opening to update data when mailmerge running"
i'm using ms office 2016

how to make vba/macro for my case..
i hope someone would help me out.

susan

User avatar
Charles Kenyon
4StarLounger
Posts: 596
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: VBA:Don't Show SQL Command Box When Opening Mail Merge in Ms Word

Post by Charles Kenyon »

The way I do this is my primary merge template is not a merge document. That is, I disconnect the merge before I save it.
Then I use an AutoNew macro in the template to connect the merge to my data and query to select a record. No SQL message shows.

Note: It is unusual to be creating a new document. That is not the way Mail Merge is designed to work, but it works for me. The new document is a primary merge document that connects to the data in preview mode.

I then have another macro that disconnects the merge with that record filled in and locks the merge fields in the document. I expect that someone else will tell you how to simply skip the message.

I've been using this method for about thirty years to produce draft documents for clients from templates set up with merge fields.

User avatar
Charles Kenyon
4StarLounger
Posts: 596
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: VBA:Don't Show SQL Command Box When Opening Mail Merge in Ms Word

Post by Charles Kenyon »

If you want to try my method, I am happy to provide the macros that I use.