This is how the pogram runs. when i clicked the commandbutton and set the checkbox to True, then it will count the words and at the same time it will highlight the words basing from what i am inputted in Text1.Text.

There is no problem with the counter, the only problem in the program, when i placed a code to highlight the word that the counter finds, it will not stop or the documents is in hang up....


but i want this work simultaneously.... both counting as well as highlighting based on the input in Text1.Text


VB Code:
  1. With objWdRange.Find
  2.  
  3. Do While .Execute(FindText:=wdText, Format:=False, _
  4. MatchCase:=True, MatchWholeWord:=False, MatchAllWordForms:=False) = True
  5.    count = count + 1
  6.  
  7. If Checkbox1.Value = True Then
  8.    objWdDoc.Range.HighlightColorIndex = wdYellow
  9.    .ClearFormatting
  10.    .Replacement.ClearFormatting
  11.    .Replacement.Highlight = True
  12.    .Execute Replace:=wdReplaceAll
  13. End If
  14. Loop
  15.  
  16. End With