MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.
Private Function FindReplaceAnywhere(strFind As String, sReplace As String, Optional iMode As Integer = 0) Dim rngStoryType As Word.Range Dim rngCurrentStory As Word.Range ' Go through all story ranges in the document, including shapes, headers, footers, text boxes footnotes ' headers & footers. For Each rngStoryType In ActiveDocument.StoryRanges Set rngCurrentStory = rngStoryType 'set rngCurrentStory to first range in story Do FindAndReplaceInRange rngCurrentStory, strFind, sReplace, iMode Set rngCurrentStory = rngCurrentStory.NextStoryRange Loop Until rngCurrentStory Is Nothing Next rngStoryType End Function Private Sub FindAndReplaceInRange(rng As Word.Range, strFind As String, sReplace As String, Optional iMode As Integer = 0) With rng.Find .Text = strFind With .Replacement .ClearFormatting .Text = sReplace End With If iMode = 1 Then .Execute Replace:=Word.WdReplace.wdReplaceOne Else .Execute Replace:=Word.WdReplace.wdReplaceAll End If End With End Sub