Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 09-10-2017, 09:13 PM
macropod's Avatar
macropod macropod is offline Macro to hide all paragraphs that do not have the found result Windows 7 64bit Macro to hide all paragraphs that do not have the found result Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Start off by hiding all text, then unhiding the paragraphs containing the found text. There is no need to do any looping:
Code:
Sub Demo()
Application.ScreenUpdating = False
StrFnd = InputBox("Find Text with Wildcard")
If Trim(StrFnd) = "" Then Exit Sub
With ActiveDocument.Range
  .Font.Hidden = True
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[!^13]@" & StrFnd & "*^13"
    .Font.Hidden = True
    .Replacement.Font.Hidden = False
    .Replacement.Text = "^&"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to hide all paragraphs that do not have the found result Show/hide paragraphs based on upfront decisions miscia76 Word 1 11-13-2013 04:29 PM
Show & hide paragraphs, parts of tables, etc Preloader Word 2 10-19-2013 02:37 PM
Macro to hide all paragraphs that do not have the found result add the functionality to show & hide paragraphs, parts of tables, etc pgwolfe Word 3 09-24-2013 07:58 PM
the macro cannot be found or has been disabled map7 Word 10 04-10-2012 01:40 PM
Macro to hide all paragraphs that do not have the found result Eliminate paragraph breaks geobruin Word 1 06-12-2009 06:55 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:19 PM.


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