Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 01-14-2020, 03:37 PM
Guessed's Avatar
Guessed Guessed is offline Let bookmark check if there are empty bookmarks before and place sentence there? Windows 10 Let bookmark check if there are empty bookmarks before and place sentence there? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Let bookmark check if there are empty bookmarks before and place sentence there? Field Code: Show a value only if bookmark is not empty Cosmo Word 7 08-24-2018 01:46 PM
Let bookmark check if there are empty bookmarks before and place sentence there? Removing spaces in activedocument after empty bookmarks faustino909 Word VBA 2 08-03-2018 01:34 PM
Let bookmark check if there are empty bookmarks before and place sentence there? VBA, Place Sentence in its own Line ilcaa72 Word VBA 6 04-28-2017 07:01 AM
Let bookmark check if there are empty bookmarks before and place sentence there? Trying to read CSV file and place values into word bookmarks Philip1 Word VBA 5 10-27-2016 12:37 AM
Let bookmark check if there are empty bookmarks before and place sentence there? Excel vba to check to check if two columns are empty subspace3 Excel Programming 5 07-09-2015 04:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft