Hi Macropod, thanks for this. when i am recreating this code on a different word file, i am getting an error on this line .
ActiveDocument.ContentControls(2).Range.Text = StrDetails
I basically copied same code changed the Title to reflect my new title which is "Office". What am i missing? Appreciate your help
Full Code here:
Code:
Option Explicit
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
If .Title = "Office" Then
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
Exit For
End If
Next
ActiveDocument.ContentControls(2).Range.Text = StrDetails
End If
End With
End Sub