View Single Post
 
Old 09-21-2020, 01:13 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You could approach this two ways:
1. Iterate through every 'sentence' and check the value of the first three characters. eg.
Code:
Sub aTest()
  Dim aSentence As Range
  For Each aSentence In ActiveDocument.Sentences
    If Left(aSentence.Text, 3) = "com" Then
      'Do something
      Debug.Print aSentence.Text
    End If
  Next aSentence
End Sub
2. Do a find in the document for instances of "com" and then check if that appears at the start of a sentence.

#1 uses Word's definition of a sentence so it is simpler but is likely to be slower.
#2 would probably be faster but you would need to work out a definition of what constitutes a Sentence.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote