View Single Post
 
Old 01-11-2024, 05:15 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,160
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

I'm not a fan of bookmarks for this task because of the fiddly nature of having to keep recreating the bookmark after changing the text inside it. I would recommend you using Rich Text Content Controls instead to streamline this aspect.

So first create some Rich Text Content Controls in your document and for each one, set a unique name in the Title field

In your userform for each of the Checkboxes, set their Tag properties to match the Title property you applied to each of the Content Controls in the document. Then put this code in your userform code.
Code:
Private Sub CheckBox1_Click()
  DoMe CheckBox1.Tag, CheckBox1.Value
End Sub
Private Sub CheckBox2_Click()
  DoMe CheckBox2.Tag, CheckBox2.Value
End Sub
Private Sub CheckBox3_Click()
  DoMe CheckBox3.Tag, CheckBox3.Value
End Sub

Private Sub DoMe(sTag As String, bVal As Boolean)
  Dim aCC As ContentControl
  Set aCC = ActiveDocument.SelectContentControlsByTitle(sTag)(1)
  With aCC
    If bVal Then
      .Range.Text = "Title" & vbTab & "First line"
      .Range.Words(1).Bold = True
    Else
      .SetPlaceholderText Text:="Blank"   ' line doesn't need to be retained if you have already placeholder text once
      .Range.Text = ""
      .Range.Bold = False
    End If
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote