Solved

Count occurrances of word in MS Word 2010

Posted on 2011-02-20
3
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Expert Comment

by:andreizz
ID: 34936221
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 34936786
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
ID: 34938682
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

749 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