INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

MS Word 2010 Mailmerge to Individual Files

MS Word 2010 Mailmerge to Individual Files

(OP)
Hi

I'm currently using an MS Word Mailmerge template that extracts data from MS Excel 2010 and outputs to individual files based upon the MAILMERGE FIELD values. All is well except that it processes all rows, even those that have an empty cell in column A. I only want to mailmerge the rows that have a Y in column A but so far have been unable to accomplish this.

The MS Word Macro that I'm currently using is:

Sub MergeAndSaveAsIndividualFiles()
'
' Merge and save as individual files Macro
'
'
Application.ScreenUpdating = False
Dim StrFolder As String, StrName As String, MainDoc As Document, i As Long, j As Long
Const StrNoChr As String = """*./\:?|"
Set MainDoc = ActiveDocument
With MainDoc
StrFolder = "H:\My Documents\MailMerge\"
For i = 1 To .MailMerge.DataSource.RecordCount
On Error Resume Next
With .MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = i
.LastRecord = i
.ActiveRecord = i
If Trim(.DataFields("Review_Plan_No_Field")) = "" Then Exit For
StrName = .DataFields("Review_Plan_No_Field") & "_" & .DataFields("Plan_Issue")
End With
.Execute Pause:=False
End With
For j = 1 To Len(StrNoChr)
StrName = Replace(StrName, Mid(StrNoChr, j, 1), "_")
Next
StrName = Trim(StrName)
With ActiveDocument
.SaveAs FileName:=StrFolder & StrName & ".docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
.Close SaveChanges:=False
End With
Next i
End With
Application.ScreenUpdating = True
End Sub

Column A in the spreadsheet has the Label "ACTIVE".

Any help will be appreciated

John

RE: MS Word 2010 Mailmerge to Individual Files

Your macro appears to be based on my Send Mailmerge Output to Individual Files code. See, for example: http://www.msofficeforums.com/mail-merge/21803-mai...

What you need to do is add a filter to the mailmerge main document, so that only records with Y in the Active field are processed.

Cheers
Paul Edstein
[MS MVP - Word]

RE: MS Word 2010 Mailmerge to Individual Files

(OP)
Hi Paul

Thanks for the reply, I've solved the issue by creating a new sheet in the source Excel Workbook that is automatically populated when the file is saved with all of the data from the other sheets where the cell in column A "ACTIVE" has the value "Y". I've them changed the Mailmerge source for the MS Word template to use the new sheet.

John

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close