View Single Post
Old 10-09-2018, 01:38 PM
quanfirem quanfirem is offline Mac OS X Office 2016 for Mac
Join Date: Oct 2018
Posts: 1
quanfirem is on a distinguished road
Default How to combine Word 2016 documents using VBA? (Mac OS)

Hi folks,

I'm sorry to post this here, I wouldn't do so unless I was getting near my wick's end. So for work I've been given a bunch (hundreds really) of .docx files in a folder. I need to find a way to merge these altogether... on a Mac. Sigh, I would know how to do this on Windows perfectly. I've spent hours looking into things online, including manually dropping each file into the Word master viewer (risky and time consuming), Automater (doesn't work on Word 2016 anymore), manually inserting and copying (for 400 files? really?) and of course VBA. I can find plenty of examples for VBA for Windows, but I'm waaay out of my depth on a mac.

Sorry folks, any help would be amazingly appreciated.

As stated, I've tried various variants on:

Sub MergeDocuments()
Application.ScreenUpdating = False
MyPath =  ActiveDocument.Path
MyName = Dir(MyPath & "\" & " *.docx")
i = 0
Do While MyName <> ""
If MyName <> ActiveDocument.Name Then
Set wb = Documents.Open(MyPath & "\" & MyName)
Selection.WholeStory Selection.Copy
Windows(1).Activate Selection.EndKey  Unit:=wdLine
Selection.TypeParagraph Selection.Paste
i = i + 1
wb.Close False
End If
MyName = Dir
Application.ScreenUpdating =  True

I'm looking for code to loop through a folder and merge all the .docx files in it into a single master document! Thanks so much!

Last edited by quanfirem; 10-09-2018 at 01:39 PM. Reason: coding
Reply With Quote