Word Copy Multiple Documents into One | VBA Macro #21

Macro Intro

Have you ever had different Word Documents coming from various sources and need to combine them into one? Say for example a different team member is assigned to work on the Beginning, Middle, and End of a paper. Once each part is complete you have to open each Word Document, select all the content, then copy and navigate back to your original document to paste. Fortunately, there is a better way with VBA! With the Copy Multiple Documents into One macro, you can quickly combine all these Word Documents with one click! This Word macro loops through all the existing Documents found at the Folder Path. By Default, the Folder Path is the location of the Active Word Document. Each Document found is opened, copied, and pasted into the original Word Document. By Default, the content will be pasted at the End of the Document. (You can customize this and alternatively paste the Beginning) Before pasting additional text is entered to indicate where the content originated from. This helps you know if the content needs to be moved because it is out of order. Prior to running this macro, you can rename the Word Documents in a way that the order is correct instead of having to move the content after the fact. The Word Copy Multiple Documents into One macro allows you to delegate more work because you can efficiently combine all the efforts of your team. If you like this concept checkout our Excel macro that Copies Multiple Workbooks into One!

See it in Action

Watch this video to see this macro in action.

Code

Here is the code for this macro. Make sure the following References are setup before running it: Visual Basic For Applications, Microsoft Office 16.0 Object Library, Microsoft Word 16.0 Object Library

Insider Content

Here is the Insider code for this macro. This code will allow you to setup an Excel Workbook that can hold a list of Word Documents to combine, even if they are saved to different folders! You can also listed multiple folders that can be looped through looking for Word Documents to combine! Make sure the following References are setup before running it: Visual Basic For Applications, Microsoft Office 16.0 Object Library, Microsoft Word 16.0 Object Library, Microsoft Excel 16.0 Object Library

Customization

These segments of code can be customized to personalize this macro.
The Selection.HomeKey wdStory and Selection.EndKey wdStory code lines are used to determine where the additional content captured from the other Word Documents will be pasted. By Default, Selection.EndKey wdStory is used to paste additional content at the end of the Active Word Document. If you want the additional content to paste at the beginning of the Active Word Document remove the comment from Selection.HomeKey wdStory and make a comment or delete the Selection.EndKey wdStory. (Learn more about the Selection.HomeKey and Selection.EndKey method)
By Default, the FolderPath variable is set to the Active Word Document folder path to loop through the existing files and find other Word Documents to pull content from. If you want to loop through a folder that is different from the Active Word Document you can update the FolderPath variable.
This code line is used to filter out what files are appropriate to open in the folder determined from the FolderPath variable. If the File Name contains .doc in the File Extension AND the File Name is NOT the Active Word Document AND the File Name does NOT contain the ‘~’ symbol meaning it is the Active Word Document’s Lock File. If you want to add additional criteria to exclude certain file you can do so here. (Keep in mind you can always move files out of the folder or update the folder path completely.)
To help determine where the additional content originates from insert the text ***Content from [Word Document Name] before the pasted content. This will also help separate the content of multiple Word Documents from each other. Learn more about the InsertAfter method here! If you don’t want any separation of the additional content you can remove this code line or make it a comment.
This code line will remove the selection of the Content From text section and insert a NEW Paragraph. This helps ensure pasting in the additional Word Document content doesn’t overwrite where it originates from. Learn more about the Collapse method here!
When pasting in the additional content from the other Word Document(s) use the PasteAndFormat Method and the wdPasteDefault parameter. This will allow for the pasting of things like images, shapes, tables, etc. See more pasting types that can be used in the PasteAndFormat method here!
Display a MsgBox at the end of this macro to confirm that Multiple Word Documents have been copied into this one! If you don’t want this behavior remove this code line or make it a comment.
Search

First time using VBA?

The Developer Tab is an additional section of the ribbon when activated allows you access to Visual Basic in Applications like Access, Excel, Outlook, PowerPoint, Word.
Setup Now
Once the Developer Tab is available you will have the capability to update your security to allow Macros to run in the current application.
Setup Now
A sub of code is a collection of objects and variables. For the code to successfully run a library of references needs to be set.
Setup Now
Subscribe as an Insider to receive additional rights.
If you like our content and want to show your support tip us here!

Contact Us

Looking to improve your computer processes?
Leverage & Lean is here to help!

Powered By MemberPress WooCommerce Plus Integration

Free Macro

Start creating Less Clicks, More Results today!