troubleshooting Question

Word 2010 Macro to Merge Files Not Working

Avatar of Alex Campbell
Alex CampbellFlag for United States of America asked on
Visual Basic ClassicMicrosoft WordVB Script
2 Comments2 Solutions965 ViewsLast Modified:
This macro is to merge all the files in a folder into the current document BUT I would also like to be able to tell it a different folder OR even better to tell it to merge only selected files in a folder.  Number one goal is to get the merge working.

Sub MergeDocs()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "U:\MergeDocs\"
Set MainDoc = Documents.Add
strFile = Dir$(strFolder&"*.docx")
Do Until strFile = ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
End Sub
Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros