![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
![]()
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 |
![]() |
Tags |
formtext, macro, textform |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
iiiiifffff | Word VBA | 16 | 06-04-2016 01:47 AM |
![]() |
bennymc | Word VBA | 1 | 01-27-2014 04:23 PM |
![]() |
tinfanide | Word | 2 | 10-06-2012 11:04 PM |
Macro to populate a text form field based on dropdown selection | koloa | Word | 0 | 10-20-2011 11:52 AM |
Macro to mark non-coloured/non-highlighted text as hidden | PeterB | Word | 0 | 10-28-2009 07:54 AM |