View Single Post
 
Old 01-12-2024, 03:48 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The initial post included this line
If Me.CheckBox1.Value

This made me think that you had the checkboxes on a VBA Userform since 'Me' is a reference to a VBA userform.

If you ACTUALLY have Content Control Checkboxes in the body of the document then the coding can be simpler. Put this code into the ThisDocument module. You won't need any other code if you have set up your Tag/Title combinations with the Content Controls.
Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
  Dim aCC2 As ContentControl, sTag As String
  If aCC.Type = wdContentControlCheckBox Then
    sTag = aCC.Tag
    Set aCC2 = ActiveDocument.SelectContentControlsByTitle(sTag)(1)
    With aCC2
      If aCC.Checked Then
        aCC2.Range.Text = "Title" & vbTab & "First line"
        aCC2.Range.Words(1).Bold = True
      Else
        aCC2.SetPlaceholderText Text:="Blank"
        aCC2.Range.Text = ""
      End If
    End With
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote