Originally Posted by
macropod
My bad - there was a (0) missing from the code. I've updated the post. Try it now.
I made no mention of an addin - what I pointed you to is a set of macros, just like what you're already using.
I apologize, I saw the addin link at the top of the page and just assumed the whole thread was a reference to that. I actually found this macro in the thread you sent, but I can't figure out exactly how it works. My best guess from reading the code is that it is supposed to execute when you run a MailMerge? However, when I tried it nothing happened. Once the MailMerge is executed the file wouldn't have the form fields that the macro would reference, but this would be the best case scenario for what I am trying to do if you have any insight. I appreciate you getting back to me so quickly macropod.
Sub Merge_To_Individual_Files()
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 = .Path & Application.PathSeparator
For i = 1 To .MailMerge.DataSource.RecordCount
With .MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = i
.LastRecord = i
.ActiveRecord = i
If Trim(.DataFields("Last_Name")) = "" Then Exit For
'StrFolder = .DataFields("Folder") & Application.PathSeparator
StrName = .DataFields("Buyer_Name") & "_" & .DataFields("Date_")
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