Hi nrowson,
to get you started, see:
http://www.gmayor.com/replace_using_wildcards.htm
have you thought about words,
which are followed by a punctuation mark?
But you shall not stay without help.
I'd make a copy of the document in question
and try to remove all tags first, like that,
which won't give the desired result in all cases:
Sub Test5b()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "\<*\>"
.MatchWildcards = True
While .Execute
rDcm.Delete
Wend
End With
End Sub
Then you may make sure, the first and the last
character of each paragraph is a space, like that:
Sub Test5bx()
Dim oPrg As Paragraph
For Each oPrg In ActiveDocument.Paragraphs
If oPrg.Range.Characters.First <> " " Then
oPrg.Range.InsertBefore " "
End If
If oPrg.Range.Characters.Last.Previous <> " " Then
oPrg.Range.Characters.Last.InsertBefore " "
End If
Next
End Sub
Then the counting:
Sub Test5bxz()
Dim rDcm As Range
Dim lCnt As Long
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = " [a-zA-Z0-9.]{1,} "
.MatchWildcards = True
While .Execute
lCnt = lCnt + 1
Wend
End With
MsgBox lCnt
End Sub
Still some riddles, oddities and straightforward bugs
lurking behind.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"