Quote Originally Posted by gmaxey View Post
I just don't have time right now to code this out, but if the issue is the CCs in the document then you might be able to process something like this:

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oCC As ContentControl
Dim lngIndex As Long
Dim lngLE As Long
  lngIndex = 1
  For Each oCC In ActiveDocument.Range.ContentControls
    If InStr(oCC.Range.Text, "Insert") > 0 Or InStr(oCC.Range.Text, "Select") > 0 Then
      oCC.Range.Text = Replace(oCC.Range.Text, "Insert", "Field_" & lngIndex)
      oCC.Range.Text = Replace(oCC.Range.Text, "Select", "Field_" & lngIndex)
      lngIndex = lngIndex + 1
      If oCC.Type = 3 Or oCC.Type = 4 Then
        For lngLE = 1 To oCC.DropdownListEntries.Count
          If InStr(oCC.DropdownListEntries(lngLE).Text, "Insert") > 0 Or InStr(oCC.DropdownListEntries(lngLE).Text, "Select") > 0 Then
            oCC.DropdownListEntries(lngLE).Text = Replace(oCC.DropdownListEntries(lngLE).Text, "Insert", "Field_" & lngIndex)
            oCC.DropdownListEntries(lngLE).Text = Replace(oCC.DropdownListEntries(lngLE).Text, "Select", "Field_" & lngIndex)
            oCC.DropdownListEntries(lngLE).Value = oCC.DropdownListEntries(lngLE).Text
            lngIndex = lngIndex + 1
          End If
        Next
      End If
    End If
  Next
lbl_Exit:
  Exit Sub
End Sub
Thanks very much, tried to clean up without altering algorithm as wasn't doing anything when ran directly like this, however apparently it seems that if it finds more than one "SELECT" or insert inside a drop down list it renames them as the same with the current algorithm and throws this error :
"Run-time error 6215:
An entry with the same display name already exists - each entry must specify a display name"

I tried to add the counter of the found item in the naming as well to avoid, but faced a seperate error :
Sub HJ()
    Dim objCC As Integer 'ContentControl
    Dim lngIndex As Long
    Dim lngLE As Long
    Dim objCL As Integer 'ContentControlListEntry
    lngIndex = 1
     
    For objCC = 1 To ActiveDocument.Range.ContentControls.Count
        If InStr(ActiveDocument.ContentControls(objCC).Range.Text, "INSERT") > 0 Or InStr(ActiveDocument.ContentControls(objCC).Range.Text, "SELECT") > 0 Then
            ActiveDocument.ContentControls(objCC).Range.Text = Replace(ActiveDocument.ContentControls(objCC).Range.Text, "INSERT", "i_Field_" & objCC & "_" & lngIndex)
            ActiveDocument.ContentControls(objCC).Range.Text = Replace(ActiveDocument.ContentControls(objCC).Range.Text, "SELECT", "s_Field_" & objCC & "_" & lngIndex)
        lngIndex = lngIndex + 1
    
            If ActiveDocument.ContentControls(objCC).Type = wdContentControlComboBox Or _
            ActiveDocument.ContentControls(objCC).Type = wdContentControlDropdownList Then
               For lngLE = 1 To ActiveDocument.ContentControls(objCC).DropdownListEntries.Count
                   If InStr(ActiveDocument.ContentControls(objCC).DropdownListEntries(lngLE).Text, "INSERT") > 0 Or InStr(ActiveDocument.ContentControls(objCC).DropdownListEntries(lngLE).Text, "SELECT") > 0 Then
                       ActiveDocument.ContentControls(objCC).DropdownListEntries(lngLE).Text = Replace(ActiveDocument.ContentControls(objCC).DropdownListEntries(lngLE).Text, "INSERT", "ii_Field_" & lngLE & "_" & lngIndex)
                       ActiveDocument.ContentControls(objCC).DropdownListEntries(lngLE).Text = Replace(ActiveDocument.ContentControls(objCC).DropdownListEntries(lngLE).Text, "SELECT", "ss_Field_" & lngLE & "_" & lngIndex)
                       ActiveDocument.ContentControls(objCC).DropdownListEntries(lngLE).Value = ActiveDocument.ContentControls(objCC).DropdownListEntries(lngLE).Text
                       lngIndex = lngIndex + 1
                   End If
               Next
            End If
        End If
    Next
End Sub
However then face error on "Range cannot be deleted" , I am not sure how to treat the range areas....