Solved

Word Macro -  Hide all non-highlighted texts

Posted on 2016-10-19
5
32 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now