Solved

Word Macro -  Hide all non-highlighted texts

Posted on 2016-10-19
5
76 Views
Last Modified: 2016-11-02
Hello Team,

I am looking for an word macro to hide all non-highlighted and yellow highlighted text from multiple word documents.
Can you please suggest or any reference to do this.

Thanks,
Shail
0
Comment
Question by:Shailesh Shinde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 41852005
Can you clarify what you want to remain visible, please?
0
 
LVL 3

Author Comment

by:Shailesh Shinde
ID: 41853263
Hi,

Visible will be only green highlighted contents from the files.

Thanks,
Shail
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 41853514
Try this. Note more than one HighLight colours can be kept visible (line 10)
Sub ShowGreen()
    Dim rng As Word.Range
    
    Set rng = ActiveDocument.Range
    rng.Font.Hidden = True 'hide all text
    With rng.Find
      .Highlight = True
      Do While .Execute
        Select Case rng.HighlightColorIndex
            Case wdBrightGreen ', wdYellow ( any other colours to remain visible)
                rng.Font.Hidden = False
        End Select
       Loop
    End With
End Sub

Open in new window

0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 41855118
This version is slighly shorter and doesn't require the specification of the highlight colours that are to stay visible.
Sub ShowOtherHighlights()
    Dim rng As Word.Range
    
    Set rng = ActiveDocument.Range
    rng.Font.Hidden = True 'hide all text
    With rng.Find
        .Highlight = True
        Do While .Execute
            If rng.HighlightColorIndex <> wdYellow Then
                rng.Font.Hidden = False
            End If
         Loop
    End With
End Sub

Open in new window

0
 
LVL 3

Author Closing Comment

by:Shailesh Shinde
ID: 41870414
Thanks a lot! This works perfectly with slightly changed requirement.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question