top of page

Tonight, I successfully tested the below vba code, posted here by Greg Maxey. It is designed to merge multiple Word documents together.

Begin by opening a Word document, and entering Visual Basic by pressing ALT + F11. Enter this code in a new module.

You can change the extension of the Word documents referenced by the macro on this line:

strFile = Dir$(strFolder & "*.doc") ' can change to .docx

When you run the macro, it will prompt you to select a folder that contains the files you want to merge.

A new document will open which contains the contents of each source document separated by section breaks.

Sub MergeDocs()

Dim rng As Range

Dim MainDoc As Document

Dim strFile As String, strFolder As String

Dim Count As Long

With Application.FileDialog(msoFileDialogFolderPicker)

.Title = "Pick folder"

.AllowMultiSelect = False

If .Show Then

strFolder = .SelectedItems(1) & Application.PathSeparator

Else

Exit Sub

End If

End With

Set MainDoc = Documents.Add

strFile = Dir$(strFolder & "*.doc") ' can change to .docx

Count = 0

Do Until strFile = ""

Count = Count + 1

Set rng = MainDoc.Range

With rng

.Collapse wdCollapseEnd

If Count > 1 Then

.InsertBreak wdSectionBreakNextPage

.End = MainDoc.Range.End

.Collapse wdCollapseEnd

End If

.InsertFile strFolder & strFile

End With

strFile = Dir$()

Loop

MsgBox ("Files are merged")

lbl_Exit:

Exit Sub

End Sub


 
 

Don't miss that you can find and replace any single character in a Word document by preceding its alt code with a caret. So in this example we can find and replace the bullet point by searching for: ^0149

If we search for ^0128, the Euro symbol can be replaced.


 
 

You can run regular expression searches in Word that will select all email addresses, so you can copy them out, or re-format them to all be lowercase, boldfaced, and so forth.

Bring up the Find tool and check off the 'Use wildcards' option in the 'More' section. Then enter this regular expression search:

[A-z,0-9]{1,}\@[A-z,0-9,\.]{1,}

. . . and click Find In . . . Main document. Each email address will be selected.

You can modify the Regex search to find emails which include a period in the name before the domain:

[A-z,0-9]{1,}\.[A-z,0-9]{1,}\@[A-z,0-9,\.]{1,}


 
 

Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page