Quote:
Originally Posted by mstde
@macropod: in my example the name consisted of just two words, but there can be other variants, too:
..
Would your method find these variants, too?
|
No, it wouldn't, because it was written to exclude anything other than the two-word kind of example you specified.
If you want something that will catch all the examples you have now given, you could use:
Find =, [A-Z][!,]@ [A-Z][!,]@,
This will capture all instances of a comma, followed by a space, then a proper-case word, any number of characters other than a comma, finally a space and another proper-case word (hyphenated or otherwise) before a comma.
Again, the macro equivalent to italicize all such text (since I still don't know what you want to do with what you find) would be:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Font.Italic = True
.Text = ", [A-Z][!,]@ [A-Z][!,]@,"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End With
Application.ScreenUpdating = True
End Sub