Created
November 26, 2013 17:34
-
-
Save DaneWeber/7662570 to your computer and use it in GitHub Desktop.
Find All Instances of the match value. You can see the results inserted into the "Immediate" debug area. Press Ctrl+G if you don't see it. See this page if you don't know how to install a macro: http://www.gmayor.com/installing_macro.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Sub FindAllInstances() | |
Dim MyAR() As String | |
Dim i As Long | |
Dim match As String | |
match = "has" | |
i = 0 | |
Selection.HomeKey Unit:=wdStory | |
Selection.Find.Text = match | |
Do While Selection.Find.Execute = True | |
ReDim Preserve MyAR(i) | |
MyAR(i) = Selection.Information(wdActiveEndPageNumber) | |
i = i + 1 | |
Loop | |
If i = 0 Then | |
MsgBox "No Matches Found" | |
Exit Sub | |
End If | |
Debug.Print " " | |
Debug.Print "Search term: " & match | |
For i = LBound(MyAR) To UBound(MyAR) | |
Debug.Print MyAR(i) | |
Next i | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment