Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-04-2023, 09:41 PM
gmayor's Avatar
gmayor gmayor is offline Find the content by color and copy it Windows 10 Find the content by color and copy it Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The text in your pasted extract is not RGB(112,48,160) You need to check that - I recommend Color Cop -, however
Code:
Sub Macro1()
Dim oTarget As Document
Dim oDoc As Document
Dim oRng As Range, oEnd As Range
    Set oDoc = ActiveDocument
    Set oTarget = Documents.Add
    Set oRng = oDoc.Range

    With oRng.Find
        .Font.Color = RGB(128, 0, 128)
        .Text = ""
        Do While .Execute
            oRng.MoveEndUntil Chr(13)
            oRng.End = oRng.End + 1
            oRng.MoveEndUntil Chr(13)

            Set oEnd = oTarget.Range
            oEnd.Collapse 0
            oEnd.FormattedText = oRng.FormattedText
            oEnd.Collapse 0
            oEnd.InsertParagraphAfter
            oRng.Collapse 0
        Loop
    End With
    oTarget.Activate
lbl_Exit:
    Set oTarget = Nothing
    Set oDoc = Nothing
    Set oRng = Nothing
    Set oEnd = Nothing
    Exit Sub
End Sub
works for your example.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
copy/paste changes text color !!! yvessr Word 8 07-16-2019 02:44 PM
Content control font color rkferguson Word VBA 1 12-18-2018 05:06 AM
Find the content by color and copy it Changing color of instructional text in a content control box Document Specialist Word 2 08-17-2018 05:25 AM
Find the content by color and copy it Text Field [content control] - Default text color vs Filled Text color jackcoletti Word 3 02-01-2017 08:10 AM
Find the content by color and copy it Macro that can find phrase and then find another and copy jperez84 Word VBA 10 09-19-2012 04:48 PM

Other Forums: Access Forums

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