Macro to merge mulitple word doc into one word doc
Hi Experts
I am looking for a macro which will merge multiple word document placed in a folder into one document. I find the below code and it fits into my requirement. I need to amend the code to ask for the folder location instead of setting a default location to pick the word docs.
Please let me with the amendments.
Code:
Sub MergeDocs()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "P:\Doc files\New folder\New folder\" 'change to suit
Set MainDoc = Documents.Add
strFile = Dir$(strFolder & "*.doc") ' can change to .docx
Do Until strFile = ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
Loop
MsgBox ("Files are merged")
End Sub
Brilliant but what about retaining formatting?
The code works awesomely. But the docs are not laid out exactly as the originals in the new file.
Is there something I can insert into the code to retain each document's format when it's being compiled?