- Joined
- Feb 13, 2018
- Messages
- 3
- Reaction score
- 1
I can't figure out what is wrong with the following Word vba routine that I'm trying to run in Word 2016, and I would appreciate any corrections and insights into what I did wrong, i.e., what I should do to avoid getting a syntax error when I run subtest():
Code:
Sub subtest()
subFindAndReplaceFirstStoryOfEachTypeTest("Mary E. Jones Living Trust", "Sally Ford")
End Sub
Sub subFindAndReplaceFirstStoryOfEachTypeTest(strTx2Find, strReplacemtTx2bInserted)
'https://wordmvp.com/FAQs/Customization/ReplaceAnywhere.htm
Dim rngStory As Range
For Each rngStory In ActiveDocument.StoryRanges
With rngStory.Find
.Text = strTx2Find
.Replacement.Text = strReplacemtTx2bInserted
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Next rngStory
End Sub 'subFindAndReplaceFirstStoryOfEachTypeTest(strTx2Find, strReplacemtTx2bInserted)
Last edited by a moderator: