How to merge multiple documents and keep format in word?
Merging multiple documents while preserving their formatting in Word can be done using various methods. Here are a few approaches:
Merge Multiple Documents One by One with Insert Text from File Feature:
This method involves manually inserting each document into a new one.
- Create a new Word document.
- Click on the “Insert” tab in the Ribbon.
- Select “Object” and then “Text from File.”
- Navigate to the folder containing the documents you want to merge.
- Select the documents and click “Insert.”
- Repeat these steps for each document.
Note: This method doesn’t maintain original formatting.
Merge Multiple Documents in Bulk with VBA:
This involves using a VBA script to automate the merging process.
- Move all documents into the same folder.
- Rename the documents to maintain the order (e.g., Part1, Part2, etc.).
- Open the first document.
- Press Alt + F11 to open the VBA editor.
- Insert a new module.
- Copy and paste the provided VBA code into the module.
- Run the macro.
Sub MergeDocuments()
Application.ScreenUpdating = False
MyPath = ActiveDocument.Path
MyName = Dir(MyPath & “\” & “*.docx”)
i = 0
Do While MyName <> “”
If MyName <> ActiveDocument.Name Then
Set wb = Documents.Open(MyPath & “\” & MyName)
Selection.WholeStory
Selection.Copy
Windows(1).Activate
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.Paste
i = i + 1
wb.Close False
End If
MyName = Dir
Loop
Application.ScreenUpdating = True
End Sub
Note: This VBA code works for .docx files.