I have a code generated RTF file that has been generated a large mail merged file, my user wants some code that will split the document and save it as separate documents. This is a not a page by page break but where a manual page break is, which marks the end and beginning of each individual letter.
I have found this code on the interweb thingy which unfortunately splits it on each page:
Code: Select all
Sub splitter()
Dim Counter As Long, Source As Document, Target As Document
Set Source = ActiveDocument
Selection.HomeKey Unit:=wdStory
Pages = Source.BuiltInDocumentProperties(wdPropertyPages)
Counter = 0
While Counter < Pages
Counter = Counter + 1
DocName = "Page" & Format(Counter)
Source.Select
Source.Bookmarks("\Page").Range.Cut
Set Target = Documents.Add
Target.Range.Paste
Target.SaveAs FileName:=DocName
Target.Close
Wend
End Sub