Investigating Microsoft Word Mail Merge Thomas Bodine
mailmerge at


When I recorded a Macro in Microsoft word to MailMerge a text file and a word document, I got this function call as a part of the code.

 ActiveDocument.MailMerge.OpenDataSource  _ 
      Name:="X:\WindowsIsWierd\Temp\merge.txt", _
      ReadOnly:=False, LinkToSource:=True, _
      PasswordDocument:="",  _
      PasswordTemplate:="", _
      WritePasswordDocument:="", _
      WritePasswordTemplate:="",  _
      Revert:=False, _
      Format:=wdOpenFormatAuto, _
      Connection:="", _
      SQLStatement:="", _
      SQLStatement1 _ :="")

I was interested in eliminating extraneous Message box pop up events during the merge, since they confused my users. I noted the format argument may have something to do with it. I looked aroiund and found this information. The Format named in the argument list is probably a constant which Microsoft calls WdOpenFormat.

WdOpenFormat Constants

wdOpenFormatAuto 0
wdOpenFormatDocument 1
wdOpenFormatEncodedText 5
wdOpenFormatRTF 3
wdOpenFormatTemplate 2
wdOpenFormatText 4
wdOpenFormatUnicodeText 5
wdOpenFormatWebPages 7

I thought I might try setting the format to wdOpenFormatText (5). to see what happens.

I thought I'd create some constants and just call the opendatasource procedure in this way:

Const DontConfirmConversions = False
Const OpenReadOnly = True
Const DontLinkToSource = False
Const DontAddToRecentFiles = False
Const NoPasswordDocument = ""
Const NoPassWordTemplate = ""
Const Revert = True
Const DontWritePasswordDocument = False
Const DontWritePassWordTemplate = False
Const NoConnection = ""
Const NoSql = ""
datasource = "/temp/merge.txt"
  Set myDoc = myapp.Documents.Open(MMDocument)
  Set myMMo = myDoc.MailMerge
  Call myMMo.opendatasource( _
        datasource, _
        wdOpenFormatText, _
        DontConfirmConversions, _
        OpenReadOnly, _
        DontLinkToSource, _
        DontAddToRecentFiles, _
        NoPasswordDocument, _
        NoPassWordTemplate, _
        Revert, _
        DontWritePasswordDocument, _
        DontWritePassWordTemplate, _
        NoConnection, _
        NoSql, NoSql)

The result of doing this is that the Popups disappeared.

A disturbing observation was that on one machine running Windows 2000 had a difficulty starting Word from MS-Access. I had to write a seperate VBscript program to seperately start Word before Access started. On other systems MS-Access started Word easily when required.

To Investigate Later