Hello all,
I am trying to use a macro that splits a mail merge into multiple word files. Below is the code that I am using. This macro works great except that it ignores the spacing of my mail merged word doc. It turns:
Line1
Line2
line3
into
Line1
Line2
Line3
How can I preserve the original spacing into the new docs?
Code:
Sub Spliter()
'Used to set criteria for moving through the document by section.
Application.Browser.Target = wdBrowseSection
'A mailmerge document ends with a section break next page.
'Subtracting one from the section count stop error message.
For i = 1 To ((ActiveDocument.Sections.Count) - 1)
'Select and copy the section text to the clipboard
ActiveDocument.Bookmarks("\Section").Range.Copy
'Create a new document to paste text from clipboard.
Documents.Add
Selection.Paste
'Removes the break that is copied at the end of the section, if any.
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
ChangeFileOpenDirectory "C:\"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="Testing_" & DocNum & ".doc"
ActiveDocument.Close
'Move the selection to the next section in the document
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Here is the site I got the original code from:
HTML Code:
http://word.tips.net/T001538_Merging_to_Individual_Files.html
An update on this issue. I figured out formatting issue for the text. I replaced:
Selection.Paste
with
Selection.PasteAndFormat (wdFormatOriginalFormatting)
The last thing that is giving me a head on this issue is that the header and footer are not keeping their formats. Any ideas?