View Single Post
 
Old 06-06-2014, 08:10 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 1,033
gmaxey will become famous soon enoughgmaxey will become famous soon enough
Default

Here is another variation. Not better just different:

Code:
Sub Demo()
Dim oRng As Word.Range
Dim i As Long, j As Long
Dim bFound As Boolean
  Application.ScreenUpdating = False
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "<[A-Z][! ]@>"
    .Wrap = wdFindStop
    .MatchWildcards = True
    While .Execute
      bFound = True
      oRng.MoveEnd wdWord, 6
      For i = 2 To oRng.Words.Count
        If Not oRng.Words(i).Characters(1) Like "[A-Z]" Then bFound = False
      Next
      If bFound = True Then
        j = j + 1
        MsgBox oRng.Text
      End If
      oRng.Collapse wdCollapseEnd
    Wend
  End With
  Application.ScreenUpdating = True
  MsgBox j & " instances found."
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote