I have a complete Access database and a Word document, and I want to merge them using VBA through Word. Setting up the merge, I have the following:
Sub MergeTest
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Users...MailMerge.accdb",_
ConfirmConversions:=False,_
ReadOnly:=False,_
LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",_
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False,_
Format:=wdOpenFormatAuto,
End Sub
I know there are more parameters to the OpenDataSource command, but I'm not quite sure what to have for those. Regardless, once the documents are merged, I know it's something like:
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="Year"
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="Volume"
To add labels. Thing is, this requires me to select each region on the sheet before executing the command. Is there a way to mark the regions on the document to be referred to in script?