View Single Post
 
Old 04-28-2022, 07:14 PM
manishhb2000 manishhb2000 is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2022
Posts: 1
manishhb2000 is on a distinguished road
Default

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

Last edited by macropod; 04-29-2022 at 06:23 PM. Reason: Added code tags
Reply With Quote