Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-04-2011, 01:17 PM
Carolin Carolin is offline Need macro to merge files in Word and preserve formatting Windows XP Need macro to merge files in Word and preserve formatting Office 2010 32bit
Novice
Need macro to merge files in Word and preserve formatting
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting macro Ulodesk Word Tables 9 04-10-2012 06:37 PM
Need macro to merge files in Word and preserve formatting macro to pull data from multiple files psrs0810 Excel 2 10-25-2010 01:49 PM
Need macro to merge files in Word and preserve formatting Cut and paste a range of cells and preserve formatting StarWeaver Excel 1 03-02-2010 01:41 PM
Macro to export document sections to individual txt files? MJMR999 Excel Programming 0 02-18-2010 12:49 PM
Help-overwriting files-could it be macro virus? Timpotty Word 0 03-06-2009 04:28 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft