View Single Post
 
Old 02-04-2011, 01:17 PM
Carolin Carolin is offline Windows XP Office 2010 32bit
Novice
 
Join Date: Feb 2011
Posts: 1
Carolin is on a distinguished road
Question Need macro to merge files in Word and preserve formatting

I have tried macros found on the web but they don't work right. I need to merge multiple files in Word 2010, insert a page break after each file, and especially preserve all the formatting and images on each original file. This will merge the files but no page break and formatting messed up:
Sub MergeDocs()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "V:\1 My Documents\cjd\Recipes\2011\MergeTest\" 'change to suit
Set MainDoc = Documents.Add
strFile = Dir$(strFolder & "*.docx") ' can change to .docx
Do Until strFile = ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
Loop
End Sub

Other variations, such as merge as images, have runtime errors. Any suggestions? Thank you
Reply With Quote