Brant,
The answer depends on whether you really want to hide the inapplicable
sections or if it's acceptable to omit the sections entirely. Omitting the
sections is easier; hiding them a bit more difficult - especially in light of
the requirement to maintain the numbering integrity. (I'm assuming that the
numbering is applied through the use of a numbered style of some sort, and if
it's not I'd suggest that it be changed to work that way.)
If omitting the sections entirely is acceptable then there are a couple of
solutions:
You can wrap a bookmark around each section and delete the bookmark range
based on the user's input. The code would look something like this:
If CheckBox1.Value = False Then
ActiveDocument.Bookmarks("Section1").Range.Delete
Alternatively, you could start with a blank page containing a series of
bookmarks as placeholders for each section, and then use AutoText entries to
insert the appropriate content - something like this:
If CheckBox1.Value = True Then
ActiveDocument.AttachedTemplate.AutoTextEntries("Section1").Insert
ActiveDocument.Bookmarks("Section1").Range, True
If the inapplicable sections _must_ be hidden (perhaps because the users
need to be able to rerun the macro and add sections back in) then wrap a
bookmark around the sections as above and then set the .Hidden property of
the bookmark range accordingly - like so:
If CheckBox1.Value = True Then
ActiveDocument.Bookmarks("Section1").Range.Font.Hidden = False Else
ActiveDocument.Bookmarks("Section1").Range.Font.Hidden = True
However, in this case you will need to do something to the section title to
sort out the numbering - possibly by changing the style to a non-numbered
one. This can be tricky, and the macro needs to address re-applying the
original style if the macro is rerun and the section restored.
Obviously these are extremely stripped down examples, but it should give you
an idea of where to begin. You would want to add some error handling (if, for
example, a bookmark was missing or an AutoText entry couldn't be found), and
you'd probably want to avoid working with the ActiveDocument object if you
can help it. You might also want to do something about retaining / restoring
the bookmarks if you need to support rerunning the macro - possibly by
ensuring that the bookmarks are included in the AutoText entry or by adding
the bookmark back in through the use of a Range object. Alternatively, there
might be a bit of clean required to remove the extraneous bookmarks if you
don't need them again. See my earlier posts in the 13 May thread entitled
'Userform question' for more info on a lot of this stuff.
Feel free to ask if you have any questions. Good luck!
--
Cheers!
Gordon
The Kiwi Koder
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.