Solved

Word Macro -  Hide all non-highlighted texts

Posted on 2016-10-19
5
65 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
  • 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

765 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