Create a Word VBA Macro to Replace English Words with French Equivalents
Question details
The user wants to replace selected English words with French equivalents after writing a document, using an easy-to-maintain list.
- Product
- Microsoft Word and Microsoft Excel
- Device & OS
- not provided
- Scenario
- A document is written in English, and predefined word pairs are applied after editing.
- Observed behavior
- The desired result is a document with listed English words replaced by their French equivalents.
Prepare an Excel workbook with English words in column A and French equivalents in column B of the first worksheet, starting in row 1 without headers. Save and close the workbook, and make sure Word can run VBA macros and Excel is installed.
Replace Words in Word Using an Excel List and VBA
Use this macro when you want to maintain replacement pairs in Excel and apply them to the main body of the active Word document.
The macro reads the first worksheet into an array and replaces whole-word matches, ignoring case. It processes the main document body, including tables, but not separate headers, footers, footnotes, or other story ranges.
Pairs run in worksheet order, so a later pair can replace text produced by an earlier pair. Test the list on a copy and review the results; this is a word replacement tool, not a context-aware translation service.
In Excel, enter each English word in column A and its French equivalent in column B. Do not add a header row. Save and close the workbook.
In Word, open the document to update, then press Alt+F11 or open the Developer tab and select Visual Basic.
In the VBA editor, select Insert > Module and paste the following code: Sub ReplaceEnglishWithFrench() Dim xl As Object, wb As Object, ws As Object Dim picker As FileDialog, pairs As Variant Dim lastRow As Long, i As Long Dim docRange As Range Dim filePath As String, message As String Set picker = Application.FileDialog(3) With picker .Title = "Select the replacement workbook" .AllowMultiSelect = False .Filters.Clear .Filters.Add "Excel workbooks", "*.xlsx;*.xlsm;*.xls" If .Show <> -1 Then Exit Sub filePath = .SelectedItems(1) End With On Error GoTo Failed Set xl = CreateObject("Excel.Application") xl.Visible = False xl.DisplayAlerts = False xl.AutomationSecurity = 3 Set wb = xl.Workbooks.Open(filePath, 0, True) Set ws = wb.Worksheets(1) lastRow = ws.Cells(ws.Rows.Count, 1).End(-4162).Row pairs = ws.Range("A1:B" & lastRow).Value2 For i = 1 To UBound(pairs, 1) If Not IsError(pairs(i, 1)) And Not IsError(pairs(i, 2)) Then If Len(Trim$(CStr(pairs(i, 1)))) > 0 And Len(Trim$(CStr(pairs(i, 2)))) > 0 Then Set docRange = ActiveDocument.Content With docRange.Find .ClearFormatting .Replacement.ClearFormatting .Text = Trim$(CStr(pairs(i, 1))) .Replacement.Text = CStr(pairs(i, 2)) .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute Replace:=wdReplaceAll End With End If End If Next i message = "Replacement complete. Review the document before saving." GoTo CleanUp Failed: message = "Replacement stopped: " & Err.Description & vbCrLf & "Some replacements may already have been made." CleanUp: On Error Resume Next If Not wb Is Nothing Then wb.Close False If Not xl Is Nothing Then xl.Quit MsgBox message End Sub
Return to Word, select Developer > Macros, choose ReplaceEnglishWithFrench, and click Run. Select the Excel workbook when prompted, then review the document before saving.

Edit Word Documents and Replacement Lists in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for editing documents and spreadsheets. Its Microsoft Office format compatibility helps you move existing files between suites. The Word VBA and Excel automation macro above is specific to Microsoft Office and is not a WPS fix.

Frequently Asked Questions
How do I add or change French equivalents later?
Open the replacement workbook in Excel and edit or add pairs in columns A and B of the first worksheet. Save and close it before running the macro again.
Does the macro replace parts of longer words?
No. The macro sets Word Find's MatchWholeWord option to True, so it targets whole-word matches rather than occurrences inside longer words.
Will replacements affect headers and footers?
No. The macro uses ActiveDocument.Content, which covers the main document story. Separate headers, footers, and other story ranges require additional code.
What happens if a French replacement matches another English entry?
The pairs are processed in worksheet order, so a later entry can replace text inserted by an earlier one. Check the list for overlaps and test it on a copy.
Why might the macro not run?
Check that Excel is installed and that your Word macro security policy allows trusted VBA code to run. In Word, open Developer > Macros to select and run the procedure.




