I'm still having trouble getting that code to run from my global macros.dotm in my STARTUP folder. However, I stuck it directly into the doc and had a bit more success, though still with Debug errors.
VBA didn't like this line: Selection.HomeKey wdStorey
So I changed it to wdStory (i.e. no 'e') and it seems to have worked without error! I also had to put the colon back into this line and get rid of the spaces around the '=': .Execute Replace:=wdReplaceAll
So the final code that worked on my test doc is:
Sub ReplaceFromTableList()
' from Doug Robbins, Word MVP, Microsoft forums, Feb 2015, based on another macro written by Graham Mayor, Aug 2010
Dim oChanges As Document, oDoc As Document
Dim oTable As Table
Dim oRng As Range
Dim rFindText As Range, rReplacement As Range
Dim i As Long
Dim sFname As String
'Change the path in the line below to reflect the name and path of the table document
sFname = "C:\Users\rhonda\AppData\Roaming\Microsoft\Word\STARTUP\find_and_replace_routines_macro.docx"
Set oDoc = ActiveDocument
Set oChanges = Documents.Open(FileName:=sFname, Visible:=False)
Set oTable = oChanges.Tables(1)
For i = 1 To oTable.Rows.Count
Set oRng = oDoc.Range
Set rFindText = oTable.Cell(i, 1).Range
rFindText.End = rFindText.End - 1
Set rReplacement = oTable.Cell(i, 2).Range
rReplacement.End = rReplacement.End - 1
Selection.HomeKey wdStory
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.Text = rFindText.Text
.Replacement.Text = rReplacement.Text
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Next i
oChanges.Close wdDoNotSaveChanges
End Sub
I'm now running it on a complex 400p test doc, with some 110 F&R routines in the file with the table in it. If it works, it will replace some 5000 instances where non-breaking spaces were required -- thus saving me a mountain of time running various F&R
routines. (Finished! It took about 4 minutes!!!)
Thank you SO much!