View Single Post
 
Old 05-15-2022, 10:39 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 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

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