G
Greg Maxey
I was reading a New User posting earlier today and became interested in
creating a macro to change the text color of a dropdown field result. I
have a single dropdown field with the List Entries Red, Blue, Green. I came
across a macro that Doug Robbins provided me last year and modified it as
follows.
Sub ChangeFontColor()
Dim DropDown
DropDown = ActiveDocument.FormFields(1).DropDown.Value
If DropDown = 1 Then
With ActiveDocument
.FormFields(1).Select
.Sections(1).ProtectedForForms = False
Selection.Font.Color = wdColorRed
.Sections(1).ProtectedForForms = True
End With
End If
If DropDown = 2 Then
With ActiveDocument
.FormFields(1).Select
.Sections(1).ProtectedForForms = False
Selection.Font.Color = wdColorBlue
.Sections(1).ProtectedForForms = True
End With
End If
If DropDown = 3 Then
With ActiveDocument
.FormFields(1).Select
.Sections(1).ProtectedForForms = False
Selection.Font.Color = wdColorGreen
.Sections(1).ProtectedForForms = True
End With
End If
End Sub
Is this an efficient method? What would be more efficient if I had say 100
similiar dropdown fields in a large document? I mean how would I loop
through all dropdown fields in a document and set the font color based the
Value 1, 2, or 3 without having to create a 100 similiar macros?
As always thanks for all the help you provide.
creating a macro to change the text color of a dropdown field result. I
have a single dropdown field with the List Entries Red, Blue, Green. I came
across a macro that Doug Robbins provided me last year and modified it as
follows.
Sub ChangeFontColor()
Dim DropDown
DropDown = ActiveDocument.FormFields(1).DropDown.Value
If DropDown = 1 Then
With ActiveDocument
.FormFields(1).Select
.Sections(1).ProtectedForForms = False
Selection.Font.Color = wdColorRed
.Sections(1).ProtectedForForms = True
End With
End If
If DropDown = 2 Then
With ActiveDocument
.FormFields(1).Select
.Sections(1).ProtectedForForms = False
Selection.Font.Color = wdColorBlue
.Sections(1).ProtectedForForms = True
End With
End If
If DropDown = 3 Then
With ActiveDocument
.FormFields(1).Select
.Sections(1).ProtectedForForms = False
Selection.Font.Color = wdColorGreen
.Sections(1).ProtectedForForms = True
End With
End If
End Sub
Is this an efficient method? What would be more efficient if I had say 100
similiar dropdown fields in a large document? I mean how would I loop
through all dropdown fields in a document and set the font color based the
Value 1, 2, or 3 without having to create a 100 similiar macros?
As always thanks for all the help you provide.