Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-09-2013, 01:58 AM
macropod's Avatar
macropod macropod is online now Highlight parent word Windows 7 64bit Highlight parent word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,382
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

Hi norgro,

The mere fact that a string can be found in various words doesn't make one the parent of the other. For what you're after, try:
Code:
Sub Demo()
With ActiveDocument.Content
  With .Find
    .ClearFormatting
    .Text = Selection.Text
    With .Replacement
      .ClearFormatting
      .Text = ""
    End With
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  While .Find.Found = True
    .Expand wdWord
    If Right(.Text, 1) = " " Then
      .End = .End - 1
    End If
    .HighlightColorIndex = wdBrightGreen
    .Collapse wdCollapseEnd
    .Find.Execute
  Wend
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlight parent word Find and highlight multiple words in MS Word document AtaLoss Word VBA 37 09-22-2021 12:04 PM
Highlight parent word how to selectively highlight text in word cnyoon2 Word 1 08-04-2015 08:16 AM
Highlight parent word Want "cloud" shape in Word, to highlight changes Arbie Word 1 03-31-2012 05:22 AM
Highlight un-identifiable wolfer Word VBA 0 08-24-2011 06:37 AM
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 03:44 AM.


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