Written by Allen Wyatt (last updated March 23, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021
Zikica has a document containing quite a few text selections that are formatted as red. He would like a way to select all instances of the red text and copy that text to a new document. He wonders if this is best done with a macro or if there is some other way to accomplish the task.
Before getting to use of a macro to accomplish the task, let's look at a few ways you can do it without using a macro. The first is to use the Find and Replace capabilities of Word by following these steps:
Figure 1. The Find tab of the Find and Replace dialog box.
Figure 2. The Find Font dialog box.
You could also use Find and Replace in a different way to arrive at a similar solution. In this approach, you start by making a copy of the document and then do your work with that copy:
Figure 3. The Replace tab of the Find and Replace dialog box.
This approach removes all non-red text in the document, leaving just the red. (This assumes that you only have regular text and red text in the document. If you have other colors you want gone, you'll need to repeat the steps and specify a different color to remove in step 5.) The one drawback to this approach is that ALL non-red text is removed, which also may include end-of-paragraph markers, so your red text may all appear run together in a single paragraph.
Another way to copy the red text to a different document is to bypass Find and Replace and use a different tool. Follow these steps:
If you have to do this type of editing quite often, you may want to create a macro that will accomplish the task for you. There are multiple ways this could be done, but the following will suffice to show the concept. It creates a variable array for all the red text in the document, creates a new document, and then inserts the variable array's text into the new document.
Sub CopyRedTextToNewDoc() Dim i As Integer Dim a() As Variant Dim sFound As String Selection.Find.ClearFormatting Selection.Find.Font.Color = wdColorRed With Selection.Find .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Do While Selection.Find.Found ReDim Preserve a(i) sFound = Selection If Asc(Right(sFound, 1)) <> 13 Then sFound = sFound & vbCrLf End If a(i) = sFound i = i + 1 Selection.Find.Execute Loop Application.Documents.Add For i = LBound(a) To UBound(a) ActiveDocument.Range.InsertAfter a(i) Next ' If you don't want the text in the new document to be red, ' remove the following three lines or comment them out Selection.WholeStory Selection.Font.Color = wdColorRed Selection.Collapse End Sub
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (379) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.
Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!
My fat fingers sometimes result in typing letters in the wrong order. Here's a quick tool that allows you to easily ...
Discover MoreWhen comparing two pieces of text, you may find that Word's smart quotes can mess up the comparison. Here's a quick way ...
Discover MoreWord does a pretty good job of figuring out what apostrophes to use around your text. There may be times, however, when ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments