In searching for mail merge automation I came across this site and found this example quite helpful as it seems to fit my needs. I will be calling it from an excel macro:
[VBA]Private Sub Document_Open()
With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
ActiveDocument.Close
End Sub
[/VBA]
[VBA]
Sub DoMerge()
ActiveWorkbook.FollowHyperlink Address:="C:\Atest\MPrint.doc", _
NewWindow:=True
End Sub
[/VBA]
The only thing I need to change is the default LastRecord value to a value contained in a cell in the excel workbook sheet. I have a macro that filters the information based on user input and as a result the number of recipients varies. The cell in excel calculates the number of recipients. Using the default value prints numerous extra pages.
I know how to pull data from closed workbooks in excel but I can't seem to do it in word for some reason.
Any help would be appreciated.