View Single Post
 
Old 07-18-2014, 05:24 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

The forum is full of examples of batch processing files. For the dropdown piece, it would probably be easier to just clear the existing list and fill it with a new list. The following code assumes a content control named "Job Title" and a formfield bookmarked "JobTitle" the contents of each are cleared and filled with a new list.

Just pass your document to process to the macro.

HTML Code:
Sub RefillDD(oDoc As Word.Document)
'A basic Word macro coded by Greg Maxey
Dim arrLEs() As String
Dim lngIndex As Long
Dim lngPT As Long
Dim bProt As Boolean
  lngPT = oDoc.ProtectionType
  If lngPT <> wdNoProtection Then
    bProt = True
    oDoc.Unprotect
  End If
  On Error Resume Next
  arrLEs = Split("X,Y,Z", ",")
  With oDoc.SelectContentControlsByTitle("Job Title").Item(1)
    For lngIndex = .DropdownListEntries.Count To 1 Step -1
      .DropdownListEntries(lngIndex).Delete
    Next lngIndex
    For lngIndex = 0 To UBound(arrLEs)
      .DropdownListEntries.Add arrLEs(lngIndex), arrLEs(lngIndex)
    Next lngIndex
  End With
  With oDoc.FormFields("JobTitle")
    .DropDown.ListEntries.Clear
    For lngIndex = 0 To UBound(arrLEs)
      .DropDown.ListEntries.Add arrLEs(lngIndex)
    Next lngIndex
  End With
  If bProt = True Then
    Select Case lngPT
     Case 2
       oDoc.Protect 2, True
     Case Else
       oDoc.Protect lngPT
    End Select
  End If
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote