Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List all occurrences or instances of a word in Word 2

Status
Not open for further replies.

sxschech

Technical User
Jul 11, 2002
1,034
US
Is it possible to list all the instances that a word appears in a Word 2000 document?

Example: Search (Find) Demineralized
Listing Results:

Ideal Display...

[tt]
Instance Page No.
-----------------------
Demineralized 10
demineralized 23
deMineralized 24
-----------------------
[/tt]

Second Option...

[tt]
Instance Count
-----------------------
Demineralized 10
demineralized 3
deMineralized 1
-----------------------
[/tt]

If Page No. or Count isn't available just knowing the variations would be sufficient.


Thanks.
 
Hi sxschech,

It desn't look like the Words Collection is really what you want. Why not just use Find? This might need a bit of tidying up but should do what you want:

Code:
[blue]    Dim SearchString As String
    SearchString = InputBox("List What?")
    Selection.HomeKey wdStory
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = SearchString
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Do While Selection.Find.Found
        Debug.Print Selection.Text & " " & Selection.Information(wdActiveEndPageNumber)
        Selection.Find.Execute
    Loop[/blue]

By the way, did you have any joy with Skip's suggestion?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Tony,

Thanks for your code, it worked great. Really appreciate you providing the answer. Skip's suggestion seemed a bit too complicated considering the size of the document I was given to work with. A star for you. Also a star for PHV for spending time on it and getting most of the way there.

--Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top