View Single Post
 
Old 09-16-2014, 04:40 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
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

It probably is The Select Vessel prompt will be the first item in the list so we can read that instead of the field name. The only time you might have a problem is if there are two similar dropdowns in the same document. Only one of them can be called 'drpVessel'. The macro therefore only processes the first such field. For multiple such fields in the same document, you would have to introduce a counter to add to the name.

Code:
Function Ddown(oDoc As Document) As Boolean
Dim oFF As FormField
Dim i As Long
    On Error GoTo Err_Handler
    For Each oFF In oDoc.FormFields
        If oFF.Type = wdFieldFormDropDown Then
            If InStr(1, LCase(oFF.Dropdown.ListEntries(1).Name), "select vessel") > 0 Then
                With oFF
                    .Name = "drpVessel"
                    'With .Dropdown.ListEntries
                    '    .Clear
                    '    .Add "Item 1"
                    '    .Add "Item 2"
                    '    .Add "Item 3"
                    '    .Add "Item 4"
                    'End With
                End With
                Exit For
            End If
        End If
    Next oFF
    Ddown = True
lbl_Exit:
    Exit Function
Err_Handler:
    Ddown = False
    Resume lbl_Exit
End Function
__________________
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