GenovSvetoslav

Combine Multiple Word Documents into a Single File on macOS

If you've ever found yourself with a folder full of individual Word documents that all need to become one cohesive file, you know the pain of manual copy-pasting. The native Word commands, such as Insert > Text from File and Insert > File, do not permit selecting multiple documents on my Mac (macOS 15.4.1 and Word 16.52), and since my Automator application lacks the Combine Word Documents action, I developed this small VBA macro. It provides a reliable and direct solution for merging multiple documents in bulk. Instead of opening each document, selecting all content, copying it, pasting it into your master document, and then inserting a page break by hand, this script does it all for you.

⚠️ Disclaimer: This script will only work on macOS versions of Microsoft Word.

Implementing the macro is straightforward:

  1. Open Word.
  2. Press Option + F11 to open the VBA editor.
  3. In the Project Explorer (usually on the left), double-click ThisDocument under your active document's project.
  4. Paste the macro code.
  5. Close the VBA editor.
  6. You can then run it from Tools > Macro > Macros or assign it to a button on your Quick Access Toolbar for one-click access.
Sub MergeDocumentsFromFolder()

    Dim folderPath As String
    Dim fileName As String
    
    ' Get path from user
    folderPath = MacScript("return POSIX path of (choose folder with prompt ""Select folder to merge."")")
    
    ' Exit if cancelled
    If folderPath = "" Then MsgBox "Operation cancelled.", vbInformation: Exit Sub
    
    ' Start search
    fileName = Dir(folderPath & "*.doc*", vbNormal)
    
    ' Loop, insert file, add section break (if more files exist)
    Do While fileName <> ""
        Selection.InsertFile FileName:=folderPath & fileName
        fileName = Dir()
        If fileName <> "" Then Selection.InsertBreak Type:=wdSectionBreakNextPage
    Loop
    
    MsgBox "Merge Complete!", vbInformation

End Sub

I hope this script saved you some time today. Enjoy!