Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2019, 08:40 AM
razdul razdul is offline Make paragraphs appear according to specific combination Windows 7 64bit Make paragraphs appear according to specific combination Office 2013
Novice
Make paragraphs appear according to specific combination
 
Join Date: Apr 2019
Posts: 2
razdul is on a distinguished road
Default Make paragraphs appear according to specific combination

Hello,



I'm fairly new to Word VBA programming.

I have a certain project that has plenty of constraints.

I would like certain paragraphs to appear according to a specific combination of checkboxes. A drop down list can be used also to replace the checkboxes to simplify the document.

Those paragraph could be in form of an autotext and a bookmark to help specify the location.

Ideally, I'm trying to make it work without the use of a userform.

The goal is to produce a universal tool, but also minimizing the information conveyed to the reader.

I have messed around with some code, but I can't seem to make the paragraphs replace each other if the initial choices change.

Thank you
Attached Files
File Type: docx combinations.docx (19.6 KB, 5 views)
Reply With Quote
  #2  
Old 04-16-2019, 06:29 PM
Guessed's Avatar
Guessed Guessed is online now Make paragraphs appear according to specific combination Windows 10 Make paragraphs appear according to specific combination Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,980
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

OK, so you set up the checkboxes using CheckBox content controls. Bookmark the show/hide text ranges with a specific name. Put that bookmark name in the tag property for each checkbox that must be checked to show that particular bookmark.

Then add the following macro into your ThisDocument module
Code:
Private Sub Document_ContentControlOnExit(ByVal myCC As ContentControl, Cancel As Boolean)
  Dim aCC As ContentControl, bChecked As Boolean, sTag As String
  sTag = myCC.Tag
  bChecked = True   'set initial value
  If ActiveDocument.Bookmarks.Exists(sTag) Then
    For Each aCC In ActiveDocument.SelectContentControlsByTag(sTag)
      bChecked = bChecked And aCC.Checked
    Next aCC
    ActiveDocument.Bookmarks(sTag).Range.Font.Hidden = Not bChecked
  End If
End Sub
Refer to attached doc for a working example based on your doc.
Attached Files
File Type: docm combinations.docm (26.3 KB, 10 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia

Last edited by Guessed; 04-16-2019 at 07:33 PM. Reason: didn't add the sample doc
Reply With Quote
  #3  
Old 04-17-2019, 06:17 AM
razdul razdul is offline Make paragraphs appear according to specific combination Windows 7 64bit Make paragraphs appear according to specific combination Office 2013
Novice
Make paragraphs appear according to specific combination
 
Join Date: Apr 2019
Posts: 2
razdul is on a distinguished road
Default

Wow it works perfectly!

Thank you very much!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Make Autocorrect Case-Specific? rjb Word 4 11-19-2018 09:11 PM
Make paragraphs appear according to specific combination keep specific paragraphs in word documents in a folder modiria50989 Word VBA 7 08-14-2017 05:31 PM
Trouble Formatting Specific Paragraphs - Bullets, Spacing, Centering, etc adzialo Word 2 05-01-2017 12:53 PM
Make paragraphs appear according to specific combination VBA to set format for paragraphs that meet with specific requirements AustinBrister Word VBA 3 06-01-2015 07:00 AM
Make paragraphs appear according to specific combination Macro to Insert text into the beginning on specific paragraphs unless the paragraph is blank caboy Word VBA 2 04-01-2015 07:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:37 AM.


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