bold all rows wher is particular word (.doc)

Zeljko

New member
Joined
Apr 22, 2007
Messages
1
Programming Experience
Beginner
VB.net 2005 express
Office Word 2003
Office 11 library => references

My level: beginner :)

I need to transfer this 2 subs from VBA to VB.net
-it works in Word VBA but i try and i try and i cant acomplish that in VB.NET. My maximum ist that I open .doc and bold only the first row where is first instance of word "tree", second row dont work...
Can anybody help?

I need to make from VB.net search in Word for these words: "tree", "bus",
"car"...(complete list contains ca. 150 words)
when find founds word "tree", BOLD entire Row (where is that word "tree"),
search next instance of "tree", BOLD entire Row... do that for every row where is word tree
then go to next word

VB.NET:
Sub DoFindBold(FindText As String) 'VBA code
 Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
   .Text = FindText
   .MatchCase = True
   .MatchWholeWord = True
   .MatchWildcards = False
   .MatchSoundsLike = False
   .MatchAllWordForms = False
While .Execute
      rDcm.Select
      rDcm.Bookmarks("\Line").Range.Font.Bold = True
   Wend
End With
End Sub
VB.NET:
Sub Office_Bold() 'VBA code
Application.ScreenUpdating = False
    Call DoFindBold("bus")
    Call DoFindBold("tree")
    Call DoFindBold("car")
    '150 other words
End Sub
 
Back
Top