|
-
Nov 30th, 2005, 11:28 PM
#1
Thread Starter
Lively Member
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:
With objWdRange.Find
Do While .Execute(FindText:=wdText, Format:=False, _
MatchCase:=True, MatchWholeWord:=False, MatchAllWordForms:=False) = True
count = count + 1
If Checkbox1.Value = True Then
objWdDoc.Range.HighlightColorIndex = wdYellow
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Execute Replace:=wdReplaceAll
End If
Loop
End With
-
Dec 2nd, 2005, 04:11 AM
#2
Re: Problem... Need your great help...
Hi,
Use the following code:
VB Code:
With objWdRange.Find
Do While .Execute(FindText:=wdText, Format:=False, MatchCase:=True, _
MatchWholeWord:=False, MatchAllWordForms:=False) = True
Count = Count + 1
If .Found Then
If Checkbox1.Value = True Then
objWdRange.Range.HighlightColorIndex = wdYellow
End If
End If
Loop
End With
___________________
CS.
Last edited by cssriraman; Dec 2nd, 2005 at 04:17 AM.
-
Dec 3rd, 2005, 09:04 AM
#3
Thread Starter
Lively Member
Re: Problem... Need your great help...
hi.. thanks for the help but your suggestions will highlight all the text in the word documents....
-
Dec 3rd, 2005, 01:14 PM
#4
Re: Problem... Need your great help...
-
Dec 3rd, 2005, 08:59 PM
#5
Thread Starter
Lively Member
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...
-
Dec 5th, 2005, 03:43 AM
#6
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:
With objWdRange.Find
Do While .Execute(FindText:=Text1.Text, Format:=False, MatchCase:=True, _
MatchWholeWord:=False, MatchAllWordForms:=False) = True
Count = Count + 1
If .Found Then
If Checkbox1.Value = True Then
objWdRange.Range.HighlightColorIndex = wdYellow
End If
End If
Loop
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.
-
Dec 5th, 2005, 05:23 AM
#7
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|