View Single Post
 
Old 05-08-2016, 10:30 AM
equalizer88 equalizer88 is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Jul 2015
Posts: 15
equalizer88 is on a distinguished road
Default

I tried and tried but could get it to Selection or ActiveDocument.Content.Find to find keyword, but it doesn't work. Why??


Range worked here below. Question: Does this search for all occurrences of "first"? No way to stop at first occurrence with this method of searching, correct?
Code:
            With .Range.Find
              '.ClearFormatting
              .Forward = True
              .Wrap = wdFindContinue
              .Format = False
              .MatchCase = False
              .MatchWholeWord = False
              .MatchWildcards = False
             '.MatchSoundsLike = False
              .MatchAllWordForms = False
              .Text = "first"
              .Execute 'Replace:=wdReplaceAll
            If .Found = True Then
                Print #DestFileNum, wdDoc.Name
            End If
                         
            End With
So I tried to modify, but this didn't find keyword:
Code:
         Selection.HomeKey Unit:=wdStory 'what does this do? It starts the search from the start of the document.
            With Selection.Find
              '.ClearFormatting
              .Forward = True
              .Wrap = wdFindContinue
              .Format = False
              .MatchCase = False
              .MatchWholeWord = False
              .MatchWildcards = False
             '.MatchSoundsLike = False
              .MatchAllWordForms = False
              .Text = "first"
              .Execute 'Replace:=wdReplaceAll
            If .Found = True Then
                Print #DestFileNum, wdDoc.Name
            End If
                         
            End With
I also tried ActiveDocument.Content.Find, but it didn't find keyword either.

Code:
             With ActiveDocument.Content.Find
              '.ClearFormatting
              .Forward = True
              .Wrap = wdFindContinue
              .Format = False
              .MatchCase = False
              .MatchWholeWord = False
              .MatchWildcards = False
             '.MatchSoundsLike = False
              .MatchAllWordForms = False
              .Text = "first"
              .Execute 'Replace:=wdReplaceAll
            If .Found = True Then
                Print #DestFileNum, wdDoc.Name
            End If
                         
            End With
Reply With Quote