Hi I have made adjustment to insert autotext instead of building blocks, but i still could not get it right. Can anyone tell me what is wrong with my code? The 2nd dropdown list not able to update the bookmark. May i know what is wrong here? Any help is appreciated. Thanks.
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long, StrDetails As String
With ContentControl
If .Title = "NameofCompany" Then
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
StrDetails = .DropdownListEntries(i).Value
Exit For
End If
Next
If StrDetails = "" Then StrDetails = "||"
With ActiveDocument.SelectContentControlsByTitle("Address")(1)
.LockContents = False
.Range.Text = Split(StrDetails, "|")(0)
.LockContents = True
End With
With ActiveDocument.SelectContentControlsByTitle("Owner")(1)
.LockContents = False
.Range.Text = Split(StrDetails, "|")(1)
.LockContents = True
End With
If .Title = "EditableC" Then
Select Case ContentControl.Title
Case "YES": Call InsertAutoTextEntry
Case Else: Call InsertAutoTextEntryNo
End Select
End If
End If
End With
Application.ScreenUpdating = True
End Sub
Sub InsertAutoTextEntry()
Dim rngDoc1 As Range
Set rngDoc1 = ActiveDocument.Range.Bookmarks("bmEditable").Range
ActiveDocument.AttachedTemplate.AutoTextEntries("EditableYes").Insert _
Where:=rngDoc1, RichText:=True
End Sub
Sub InsertAutoTextEntryNo()
Dim rngDoc1 As Range
Set rngDoc1 = ActiveDocument.Range.Bookmarks("bmEditable").Range
ActiveDocument.AttachedTemplate.AutoTextEntries("EditableNo").Insert _
Where:=rngDoc1, RichText:=True
End Sub