Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

VBA loop bold

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zeljko - 09 Apr 2006 12:33 GMT
I need to find ALL ocurances of word "Name:" or "Adress: A" or ... in that
*.doc and then boldit complete row where is that word.
Problem is that with this code it only bold rows where it finds first
ocurances of word "Name:" or "Adress: A" or ...
I try everything and i can't find solution. Plese help if u can.
To start macro i call procedure Replace_Bold

I have next code:

Sub DoFindBold(FindText As String)
  Selection.Find.ClearFormatting
  Selection.Find.Replacement.ClearFormatting
  With Selection.Find
       .Text = FindText
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .MatchCase = True
       .MatchWholeWord = True
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
       .Execute
    End With
If Selection.Find.Found Then
   Selection.HomeKey Unit:=wdLine
   Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
   Selection.Font.Bold = wdToggle
   Selection.Find.Execute
 Else
   Selection.Find.Execute
End If
End Sub

///// and another one

Sub Replace_Bold()
   Call DoFindBold("Name:")
   Call DoFindBold("Adress: A")
' ... line call continues ca. 150 times ...
End Sub
Helmut Weber - 09 Apr 2006 12:44 GMT
Hi Zeljko,

you don't need more than this in principle:

Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
  .Text = "brown"
  While .Execute
     rDcm.Select
     rDcm.Bookmarks("\Line").Range.Font.Bold = True
  Wend
End With

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.