Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2022, 10:39 PM
Guessed's Avatar
Guessed Guessed is offline UserForm with checkboxes that hide/show bookmarked text in document Windows 10 UserForm with checkboxes that hide/show bookmarked text in document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
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

Firstly, writing to bookmarks is non-intuitive because the added text is beside the bookmark rather than inside it. This means it works once but a second pass with the macro adds a second copy instead of replacing. You get around this shortcoming by redefining the bookmark range after writing the text. See https://www.msofficeforums.com/word-...lues-text.html for an example of this.



If you want to show/hide a range based on a checkbox, you can do it without an If statement
Code:
' Hide the text if checked, show if unchecked
ActiveDocument.Bookmarks("ContinenceCost").Range.Font.Hidden = ContinenceCB
'or vice versa 
ActiveDocument.Bookmarks("ContinenceCost").Range.Font.Hidden = Not ContinenceCB
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Tags
checkbox, show, userform



Similar Threads
Thread Thread Starter Forum Replies Last Post
Show Userform hide active document only Just Learning Word VBA 4 03-25-2020 08:57 PM
UserForm with checkboxes that hide/show bookmarked text in document Auto-populating a document pulling data from external doc using a Userform with Checkboxes kateabode Word VBA 10 10-12-2018 06:56 AM
UserForm with checkboxes that hide/show bookmarked text in document How to use checkbox to show/hide bookmarked text? namrehx Word VBA 16 12-14-2017 01:45 PM
How to use checkbox to show and hide bookmarked text? namrehx Word VBA 1 12-12-2017 02:17 PM
UserForm with checkboxes that hide/show bookmarked text in document Show userform without losing document focus? Or other method to get a graphic to pop? AlexR Word VBA 7 03-31-2013 12:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:16 PM.


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