View Single Post
 
Old 01-14-2020, 03:37 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

It appears that you are hiding text in bookmarks if the checkbox is not ticked. If that is the case, you just need to include the paragraph mark in each of the bookmarks.

Graham's suggestion is a good alternative but there is a trap there that you would need to consider. When looping through controls on a form, Word uses the order of creation, not the order from the top (if checkbox2 was created before checkbox1). If that is an issue, you can cut a checkbox and then paste it back in to make it the 'last' checkbox in the loop.

Following on Graham's method, I generally try to minimise the coding to make future updates easier by using a Concatenate function and making use of properties on each checkbox. This alternative to Graham's first macro could then be the following code
Code:
Private Sub CommandButton1_Click()
  Dim aCtl As Control, sResult As String
  For Each aCtl In Me.Controls
    If aCtl.Tag = "MyCheck" And aCtl = True Then
      sResult = Concat(sResult, aCtl.ControlTipText)
    End If
  Next aCtl
  FillBM "BookMark_Name", sResult
  Unload Me
End Sub

Private Function Concat(s1 As String, s2 As String, Optional sJoin As String = vbCr)
  If s1 = "" Then
    Concat = s2
  ElseIf s2 = "" Then
    Concat = s1
  Else
    Concat = s1 & sJoin & s2
  End If
End Function
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote