Hi Jonathan,
Since I don't have your code, and this is programmed from within Word, not
Access, you might need to tweak it a bit. However, this code will merge an
excel spreadsheet containing corresponding headings to a Word document's
field codes:
Sub Word2000MailMerge()
Dim strDataSource As String, strDocWithCodes As String, myDoc As Document,
strCurDoc As String
strDocWithCodes = "c:\zivcomdocsss\MergeLtrs\All Fields Template.doc"
strDataSource = "c:\zivcomdocsss\contacts\filtered\ziv.xls"
Documents.Open strDocWithCodes
Set myDoc = ActiveDocument
myDoc.MailMerge.MainDocumentType = wdFormLetters
myDoc.MailMerge.OpenDataSource Name:= _
strDataSource, ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:="Entire Spreadsheet", SQLStatement:="", SQLStatement1:=""
With myDoc.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
strCurDoc = ActiveDocument.ActiveWindow.Caption
myDoc.Close SaveChanges:=wdDoNotSaveChanges
Windows(strCurDoc).Activate
End Sub
If anyone knows how to merge the document with the field codes in it,
without actually opening it up, please add to this thread.