Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Merge multiple files into one
How can I merge multiple Word document files
into one file? Do I need to write a macro t do this? Thanks in advance. Ron |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Merge multiple files into one
You can use Insert | File. If you want to preserve a link to the
original file, after selecting the file to insert, click the arrow next to the Insert button and choose to "Insert as Link." This places an INCLUDETEXT file in the target document; to update this field after you've made changes to the original document(s), you can select the entire document and press F9. -- Stefan Blom Microsoft Word MVP "Ronald Roberts" wrote in message ... How can I merge multiple Word document files into one file? Do I need to write a macro t do this? Thanks in advance. Ron |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Merge multiple files into one
Stefan Blom wrote:
You can use Insert | File. If you want to preserve a link to the original file, after selecting the file to insert, click the arrow next to the Insert button and choose to "Insert as Link." This places an INCLUDETEXT file in the target document; to update this field after you've made changes to the original document(s), you can select the entire document and press F9. Stefan, Thanks for the help. The file insert works the way I want, but there are a couple of problems. I'm using sample data of 7 documents, Lesson 1.doc thru Lesson 7.doc. When I select all of the files using the shift key, Word inserts all of the documents into one new blank document. The problem I'm having is, they are inserted in the wrong order. the order they are inserted is Lesson 7, 1, 2, 3, 4, 5, 6. Also there is no page break between the documents. This works the same for Insert or Insert Link. What I did last night was record a macro and then add code around it for what I needed. Here is the code: Sub Macro1() ' ' Macro1 Macro ' Macro recorded 7/25/2006 by Ronald W. Roberts ' Dim MyName As String Dim MyPath As String MyPath = "D:\Computer Classes\RobCom\RobCom Introduction to Computers\" ChangeFileOpenDirectory MyPath MyPath = MyPath & "*.doc" MyName = Dir(MyPath, vbNormal) 'Get first entry Do While MyName "" ' Start the loop. Documents.Open FileName:=MyName, ConfirmConversions:=False, _ ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _ PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _ WritePasswordTemplate:="", Format:=wdOpenFormatAuto Selection.WholeStory Selection.Copy Windows(1).Activate Selection.PasteAndFormat (wdPasteDefault) Selection.InsertBreak Type:=wdPageBreak Windows(2).Activate ActiveDocument.Close wdDoNotSaveChanges MyName = Dir ' Get next entry. Loop MsgBox "Done", 48 End Sub The first DIR command returns the first file. The second DIR at the bottom of the loop without arguments, returns the next file that matches the criteria. In the DO LOOP, when MyName is returned as a zero length string, I know I'm done. Ron |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Merge multiple files into one
I'm glad you got it sorted.
Note, however, that if INCLUDETEXT fields have been inserted in the wrong order, you can move them in the user interface: simply press Alt+F9 to display field codes and then use cut and paste. When you are done, press Alt+F9 again to hide field codes. -- Stefan Blom Microsoft Word MVP "Ronald Roberts" wrote in message ... Stefan Blom wrote: You can use Insert | File. If you want to preserve a link to the original file, after selecting the file to insert, click the arrow next to the Insert button and choose to "Insert as Link." This places an INCLUDETEXT file in the target document; to update this field after you've made changes to the original document(s), you can select the entire document and press F9. Stefan, Thanks for the help. The file insert works the way I want, but there are a couple of problems. I'm using sample data of 7 documents, Lesson 1.doc thru Lesson 7.doc. When I select all of the files using the shift key, Word inserts all of the documents into one new blank document. The problem I'm having is, they are inserted in the wrong order. the order they are inserted is Lesson 7, 1, 2, 3, 4, 5, 6. Also there is no page break between the documents. This works the same for Insert or Insert Link. What I did last night was record a macro and then add code around it for what I needed. Here is the code: Sub Macro1() ' ' Macro1 Macro ' Macro recorded 7/25/2006 by Ronald W. Roberts ' Dim MyName As String Dim MyPath As String MyPath = "D:\Computer Classes\RobCom\RobCom Introduction to Computers\" ChangeFileOpenDirectory MyPath MyPath = MyPath & "*.doc" MyName = Dir(MyPath, vbNormal) 'Get first entry Do While MyName "" ' Start the loop. Documents.Open FileName:=MyName, ConfirmConversions:=False, _ ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _ PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _ WritePasswordTemplate:="", Format:=wdOpenFormatAuto Selection.WholeStory Selection.Copy Windows(1).Activate Selection.PasteAndFormat (wdPasteDefault) Selection.InsertBreak Type:=wdPageBreak Windows(2).Activate ActiveDocument.Close wdDoNotSaveChanges MyName = Dir ' Get next entry. Loop MsgBox "Done", 48 End Sub The first DIR command returns the first file. The second DIR at the bottom of the loop without arguments, returns the next file that matches the criteria. In the DO LOOP, when MyName is returned as a zero length string, I know I'm done. Ron |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I mail merge to EMAIL from MS Word AND add a pdf attachment | Mailmerge | |||
Insert multiple text files in microsoft word | Microsoft Word Help | |||
Saving final document to multiple files when merge document has multiple section | Mailmerge | |||
Combining multiple merge documents | Mailmerge | |||
Query a mail merge for multiple letters at once? | Mailmerge |