Results 1 to 7 of 7

Thread: Problem... Need your great help...

  1. #1

    Thread Starter
    Lively Member neo_phyte's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Philippines
    Posts
    71

    Question Problem... Need your great help...

    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

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Problem... Need your great help...

    Hi,

    Use the following code:
    VB Code:
    1. With objWdRange.Find
    2.     Do While .Execute(FindText:=wdText, Format:=False, MatchCase:=True, _
    3.                       MatchWholeWord:=False, MatchAllWordForms:=False) = True
    4.         Count = Count + 1
    5.         If .Found Then
    6.             If Checkbox1.Value = True Then
    7.                 objWdRange.Range.HighlightColorIndex = wdYellow
    8.             End If
    9.         End If
    10.     Loop
    11. End With
    ___________________
    CS.
    Last edited by cssriraman; Dec 2nd, 2005 at 04:17 AM.

  3. #3

    Thread Starter
    Lively Member neo_phyte's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Philippines
    Posts
    71

    Re: Problem... Need your great help...

    hi.. thanks for the help but your suggestions will highlight all the text in the word documents....

  4. #4
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Problem... Need your great help...

    Then, What you need?

  5. #5

    Thread Starter
    Lively Member neo_phyte's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Philippines
    Posts
    71

    Re: Problem... Need your great help...

    simply, when i write a word "City" in the Text1.Text... then it will count and as well highlight all the "City" in the document.... Thanks for your help...

  6. #6
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Problem... Need your great help...

    Hi,

    The following code will find the text "City" in text1.text and highlight it in the document:

    VB Code:
    1. With objWdRange.Find
    2.     Do While .Execute(FindText:=Text1.Text, Format:=False, MatchCase:=True, _
    3.                       MatchWholeWord:=False, MatchAllWordForms:=False) = True
    4.         Count = Count + 1
    5.         If .Found Then
    6.             If Checkbox1.Value = True Then
    7.                 objWdRange.Range.HighlightColorIndex = wdYellow
    8.             End If
    9.         End If
    10.     Loop
    11. End With
    So, if you enter the word "City" in text box1 it will search for it and if found then it will highlight it in the document.
    ___________________
    CS.

  7. #7

    Thread Starter
    Lively Member neo_phyte's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Philippines
    Posts
    71

    Re: Problem... Need your great help...

    just asking, even if without the method .Execute Replace:=wdReplaceAll inside the If...If...End If... End If condition... when i try run your code, it will not highlight at all...


    but when, i placed also .Execute Replace:=wdReplaceAll inside the If Condition, same thing happen this will not fix the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width