#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
The code I've posted for you at Windows Secrets (http://windowssecrets.com/forums/sho...g-bold-or-text) has already shown how you can process a whole table without the need to process cells individually. It would require very little effort on your part to adapt that code to highlighting the content of interest.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
word vba highlight text |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to selectively highlight text in word | cnyoon2 | Word | 1 | 08-04-2015 08:16 AM |
Help with VBA code to find and highlight text | mpdsal | Word VBA | 8 | 09-11-2014 03:55 PM |
Highlight text when mouseover | kxt | Word | 4 | 05-17-2012 04:21 PM |
Highlight text and find next instance | DrDOS | Word | 0 | 11-15-2010 04:02 PM |
find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |