View Single Post
 
Old 01-06-2024, 02:41 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

You have to target the right storyrange:


Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
  Set oRng = ActiveDocument.StoryRanges(wdTextFrameStory)
  Do
    With oRng.Find
      .Text = "Test"
      While .Execute
        oRng.Select
      Wend
    End With
    Set oRng = oRng.NextStoryRange
  Loop Until oRng Is Nothing
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote