Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2014, 05:19 PM
mrayncrental mrayncrental is offline Ugghhh....Highlight Text not working Windows 7 64bit Ugghhh....Highlight Text not working Office 2007
Novice
Ugghhh....Highlight Text not working
 
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
  #2  
Old 02-10-2014, 10:58 PM
macropod's Avatar
macropod macropod is offline Ugghhh....Highlight Text not working Windows 7 32bit Ugghhh....Highlight Text not working Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Tags
word vba highlight text



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ugghhh....Highlight Text not working how to selectively highlight text in word cnyoon2 Word 1 08-04-2015 08:16 AM
Ugghhh....Highlight Text not working Help with VBA code to find and highlight text mpdsal Word VBA 8 09-11-2014 03:55 PM
Ugghhh....Highlight Text not working 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft