![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#3
|
||||
|
||||
|
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 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Field Code: Show a value only if bookmark is not empty
|
Cosmo | Word | 7 | 08-24-2018 01:46 PM |
Removing spaces in activedocument after empty bookmarks
|
faustino909 | Word VBA | 2 | 08-03-2018 01:34 PM |
VBA, Place Sentence in its own Line
|
ilcaa72 | Word VBA | 6 | 04-28-2017 07:01 AM |
Trying to read CSV file and place values into word bookmarks
|
Philip1 | Word VBA | 5 | 10-27-2016 12:37 AM |
Excel vba to check to check if two columns are empty
|
subspace3 | Excel Programming | 5 | 07-09-2015 04:45 PM |