Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-29-2019, 01:57 AM
harpsichord harpsichord is offline How can I delete pages with no highlighted text? Windows 10 How can I delete pages with no highlighted text? Office 2010
Novice
How can I delete pages with no highlighted text?
 
Join Date: Apr 2019
Posts: 4
harpsichord is on a distinguished road
Default How can I delete pages with no highlighted text?

Hello all,




I am using the following module to highlight specific words in my word documents:

Code:
Sub HiLightList()
Application.ScreenUpdating = False
Dim StrFnd As String, Rng As Range, i As Long
StrFnd = "cat,pig,dog,whatever"
For i = 0 To UBound(Split(StrFnd, ","))
  Set Rng = ActiveDocument.Range
  With Rng.Find
    .ClearFormatting
    .Text = Split(StrFnd, ",")(i)
    .Replacement.ClearFormatting
    .Replacement.Highlight = True
    .Replacement.Text = "^&"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = True
    .Execute Replace:=wdReplaceAll
  End With
Next
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
It's working quite well but since I am working with thousands of Word pages of text a majority of which are irrelevant for me and contain zero information I need, I would like to know if there is a way i could somehow insert a code that would delete all pages that contain zero highlighted words? I don't need to extract only highlighted words, I need to preserve the whole text (specifically, it's 1-page-long newspaper articles) in which the highlighted words were found. Is there a simple way to do this and what would it be?


I am quite illiterate when it comes to coding or VBA or pretty much anything so I am relying on the kindness and skills of others willing to help me and write this down so I can simply insert it


Thank you!

Last edited by macropod; 04-29-2019 at 09:17 PM. Reason: Added code tags & restored formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I delete pages with no highlighted text? Cannot see highlighted text for moving text in a do ument Jonfrank1@me.com Project 1 01-09-2017 06:04 PM
How can I delete pages with no highlighted text? I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? AustinBrister Word VBA 8 05-28-2015 02:42 PM
How can I delete pages with no highlighted text? Formatting- Apply changes to highlighted text results in same change to other text sential Word 6 01-10-2014 03:22 PM
Delete button does not work with highlighted text edmund36 Word 3 10-17-2011 02:34 AM
Highlighted text won't delete - when I press enter Gague Word 2 07-09-2010 12:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:10 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