Solved

Count occurrances of word in MS Word 2010

Posted on 2011-02-20
3
330 Views
Last Modified: 2012-05-11
I am in the process of compiling a Test Report from my Test Procedures.  Need to count the number of "Pass" and "Fail" strings in a huge Word file.  All my relevant results are identified by a three asterik and then "Pass" or  "Fail" occurs.  Need quick way to compute total "Pass", "Fail", and both.
0
Comment
Question by:sdruss
3 Comments
 
LVL 4

Expert Comment

by:andreizz
Comment Utility
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
Comment Utility
Depending on your version you can simply do an advanced find for the *** pass string and find all occurences then repeat for fail or perhaps a macro like below to do it for you.

Try the following macro which looks for *** Pass and *** fail.

If necessary modify to remove space or other formatting.

Chris
Sub passfail()
Dim intpass As Integer
Dim intfail As Integer
    
    ThisDocument.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
    With ThisDocument.Content.Find
        Do While .Execute(FindText:="*** pass", Forward:=True, Format:=True, _
           MatchWholeWord:=True, MatchCase:=False)
           intpass = intpass + 1
        Loop
    End With
    ThisDocument.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
    With ThisDocument.Content.Find
        Do While .Execute(FindText:="*** fail", Forward:=True, Format:=True, _
           MatchWholeWord:=True, MatchCase:=False)
           intfail = intfail + 1
        Loop
    End With
    MsgBox "Total ""Pass"" entries =  " & intpass & vbCrLf & _
    "Total ""Fail"" entries =  " & intfail & vbCrLf & _
    "Total entries =  " & intfail + intpass

End Sub

Open in new window

0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
It can't be used programatically, but you can do it quickly with a Find and Replace. Just have the same string for the Replace and for the Find part.

Find: ***Pass
Replace: ***Pass

The number of replacements is reported after the replacing is complete.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now