View Single Post
 
Old 11-06-2022, 10:57 AM
m2ramos m2ramos is offline Windows 10 Office 2016
Novice
 
Join Date: Nov 2022
Posts: 2
m2ramos is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
Finding text with a range object doesn't select the text so your selection is where it is throughout the process:

Code:
Dim oRng As Range
Sub getPosition()
    Debug.Print oRng.Information(wdVerticalPositionRelativeToPage)
    Debug.Print oRng.Information(wdHorizontalPositionRelativeToPage)
End Sub

Sub Test()
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "Test Words"
    While .Execute
      getPosition
      oRng.Collapse wdCollapseEnd
    Wend
  End With
End Sub
Thanks for the update. With the information about select that you provided, I managed to get my code working by adding rngSearch.Select within the Do While Loop. That got me what I needed. Thank you.
Reply With Quote