Link to home
Start Free TrialLog in
Avatar of tahirih
tahirih

asked on

WORD - Word Count

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
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

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

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. User generated image
Avatar of tahirih
tahirih

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tahirih

ASKER

Thank you.