Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Word Macro -  Hide all non-highlighted texts

Posted on 2016-10-19
5
Medium Priority
?
148 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Suggested Courses

715 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