So I have a macro that i run to merge my chapters.
However, I need to insert breaks that seperate the files so i know where one ends and the next begins. (they're chapters)
This on creates a blank page for each file but they're all at the start of the document. 13 files, 14 blank pages at the beginning of the document and the no differentiation....
BEST CASE: I'd be able to merge the files, they'd keep their titles, and they'd clearly begin and end inside the document.
Please help?
Thanks!
Sub MergeDocs()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "C:\Book\Chapters\" 'change to suit
Set MainDoc = Documents.Add
strFile = Dir$(strFolder & "*.rtf") ' can change to .docx
Do Until strFile = ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
Loop
End Sub
However, I need to insert breaks that seperate the files so i know where one ends and the next begins. (they're chapters)
This on creates a blank page for each file but they're all at the start of the document. 13 files, 14 blank pages at the beginning of the document and the no differentiation....
Sub MergeDocs()
Dim rng As Range
Dim FinalEvidence As Document
Dim strFile As String
'Dim OutPut_file_name As String
Const strFolder = "C:\Test\" 'change to any dir which you wanna use
Set FinalEvidence = Documents.Add
strFile = Dir$(strFolder & "*.rtf")
Do Until strFile = ""
Set rng = FinalEvidence.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
Selection.InsertBreak Type:=wdPageBreak
Loop
' OutPut_file_name = "FinalEvidence.doc"
End Sub
BEST CASE: I'd be able to merge the files, they'd keep their titles, and they'd clearly begin and end inside the document.
Please help?
Thanks!