Solved

WORD - Word Count

Posted on 2011-03-11
5
405 Views
Last Modified: 2012-06-27
Hi,

Is there a way in WORD to set a formula where every time a specific word appears, a sequential counter can be added before or after this word?

Thanks
0
Comment
Question by:tahirih
[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
  • 2
  • 2
5 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35113363
It would need to be done programatically after the document is complete. This VBA macro would do it.
Sub WordNumber()
    Dim i As Long
    Dim rng As Range
    
    Set rng = ActiveDocument.Range
    With rng.Find
        .Wrap = wdFindStop
        .MatchWildcards = True
        .Text = "<myword>"
        Do While .Execute
            i = i + 1
            rng.Collapse wdCollapseEnd
            rng.Text = " " & i
            rng.End = ActiveDocument.Range.End
        Loop
    End With
End Sub

Open in new window

0
 
LVL 32

Expert Comment

by:Paul Sauvé
ID: 35113766
Hi t.,

When i want to find the number of times a specific word appears in a Word document, I simply replace the word with the same word and Word tells me how many of the word it changed.
 
It is much quicker to do than to write the explanation.

P. WORD - Word Count
0
 

Author Comment

by:tahirih
ID: 35115992
Let me please clarify - what is requested is not a total word count - but to actually number the words in the document.

i.e.

Word, Word, Word

would become

Word1, Word2, Word3

Thank you
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 35116111
Here is a rewritten macro. This uses 'Word' as an example instead of 'myword', and doesn't put a space before the number.
Sub WordNumber()
    Dim i As Long
    Dim rng As Range
    
    Set rng = ActiveDocument.Range
    With rng.Find
        .Wrap = wdFindStop
        .MatchWildcards = True
        .Text = "<Word>"
        Do While .Execute
            i = i + 1
            rng.Collapse wdCollapseEnd
            rng.Text = i
            rng.End = ActiveDocument.Range.End
        Loop
    End With
End Sub

Open in new window

0
 

Author Closing Comment

by:tahirih
ID: 35148699
Thank you.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

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…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
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 Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

737 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