Global Change to Drop-Down Form Fields

I

iamnu

I need to make a global change to a large number of Drop-Down form
fields. They currently have the same values, I just want to change
those values to something different.

Anyone know how to do this?
 
J

Jay Freedman

I need to make a global change to a large number of Drop-Down form
fields. They currently have the same values, I just want to change
those values to something different.

Anyone know how to do this?

You can get your knickers in a twist trying to change specific
entries, but it's simpler to just wipe out the contents of each field
and replace the whole list. Something like this example...

Sub x()
Dim dd As FormField
Dim newEntries As Variant
Dim idx As Integer

newEntries = Array("five", "six", "seven")

For Each dd In ActiveDocument.FormFields
If dd.Type = wdFieldFormDropDown Then
With dd.DropDown
.ListEntries.Clear
For idx = 0 To UBound(newEntries)
.ListEntries.Add newEntries(idx)
Next idx
.Value = 1
End With
End If
Next dd
End Sub
 
I

iamnu

You can get your knickers in a twist trying to change specific
entries, but it's simpler to just wipe out the contents of each field
and replace the whole list. Something like this example...

Sub x()
    Dim dd As FormField
    Dim newEntries As Variant
    Dim idx As Integer

    newEntries = Array("five", "six", "seven")

    For Each dd In ActiveDocument.FormFields
        If dd.Type = wdFieldFormDropDown Then
            With dd.DropDown
                .ListEntries.Clear
                For idx = 0 To UBound(newEntries)
                    .ListEntries.Add newEntries(idx)
                Next idx
                .Value = 1
            End With
        End If
    Next dd
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroupso all may benefit.

Excellent, Jay!
This is exactly what I was looking for.
Thank you very much...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top