On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.
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
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.