How to count word from statistic option and exlude.... in Work200

S

Sharon

I need to count some word in doucumnets but I need to exclude all sentences
start with "[" and end with "]" and sentence start with ";".

is their smart way to exclude those sentances ?
 
G

Graham Mayor

There's no smart way I can think of, but a macro should do it - try the
following, which will count the section with the described sentences
eliminated then it will put them back and count the full document: -

ActiveWindow.View.ShowHiddenText = False
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ";*. "
.Replacement.Text = "^&"
.Replacement.Font.Hidden = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\[*\]"
.Replacement.Text = "^&"
.Replacement.Font.Hidden = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.WholeStory

MsgBox "There are " & Selection.Words.Count & " words."
ActiveWindow.View.ShowHiddenText = True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "*"
.Font.Hidden = True
.Replacement.Text = "^&"
.Replacement.Font.Hidden = False
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.WholeStory

MsgBox "There are " & Selection.Words.Count & " words."
ActiveWindow.View.ShowHiddenText = False

If you don't know what to do with this listing, see
http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top