View Single Post
 
Old 11-26-2014, 08:12 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,076
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 of
Default

The following should find red text in the document body and put it in a text form field. The colour will be the underlying style colour.

Code:
Dim oRng As Range
Dim strText As String
Dim oFld As FormField
    Set oRng = ActiveDocument.Range
    With oRng.Find
        .ClearFormatting
        .Font.Color = wdColorRed
        .Replacement.ClearFormatting
        Do While .Execute(Forward:=True) = True
            strText = oRng.Text
            oRng.Text = vbNullString
            Set oFld = ActiveDocument.FormFields.Add(oRng, wdFieldFormTextInput)
            oFld.Result = strText
        Loop
    End With
    ActiveDocument.Protect _
     Type:=wdAllowOnlyFormFields, _
     NoReset:=True, _
     Password:=""
__________________
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