View Single Post
 
Old 02-10-2014, 05:19 PM
mrayncrental mrayncrental is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Feb 2014
Posts: 15
mrayncrental is on a distinguished road
Default Ugghhh....Highlight Text not working

OK, I'm trying to write a routine that highlights both Bold text and Text in [] in a Word table.

I have no idea why this is not working. Help!!

P.S. Any recommendations on good Word/vba reference manual?

Code:
 Dim aRng As Range, sText As String
 Dim aTbl As Table, aRow As Integer, aCell As Cell
 Dim fCount As Integer
        
    
       
    Set aTbl = ActiveDocument.Tables(1)
    Set aRng = aTbl.Range
    
    For aRow = 1 To aTbl.Rows.Count
      Set aRng = aTbl.Cell(iRow, 3).Range
      
      With aRng.Find
        .Text = "\[*\]"
        .MatchWildcards = True
        .Replacement.Highlight = True
        .Execute Replace:=wdReplaceAll
     End With
    
      Selection.Find.Font.Bold = True
      With aRng.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchSoundLike = False
        .MatchAllWordForms = False
        .MatchWildcards = False
        .Replacement.Highlight = True
        .Execute Replace:=wdReplaceAll
     End With
        
    
    Next aRow
Reply With Quote