none
How to add Expandable/Collapsible sections to my document? RRS feed

  • Question

  • I am writing a document with several paragraphs.

    I could create specific sections for some of these paragraphs if necessary but have not yet done so.

    I have created several bookmarks which are linked at the top of the document.

     

    I would like very much to add some buttons to this document which would expand (+) or collapse (-) pieces of the document.

    This would be analogous to the Expanding or Collapsing groups in Excel where you have a button with a + to expand and once expanded the symbol changes to a – and thus clicking the button again would collapse the group.

     

    I have quite a bit of experience writing VBA in Access and Excel, but have not worked with the Word Object Model yet.

    Any comments or suggestions or code samples would be GREATLY appreciated?

    Tuesday, June 21, 2011 3:46 PM

Answers

  • <<Hiding/unhiding the text is an interesting option except that I was hoping for the document to expand/contract such that sections below the the expanding/contracting section actuially move up or down (similar to expanding or contracting groups in Excel).>>

    If you hide text then the following text "moves up". This assumes, of course, that you have the display of hidden text deactivated.


    Cindy Meister, VSTO/Word MVP
    Wednesday, June 22, 2011 12:48 PM
    Moderator

All replies

  • For starters, nothing like this is supported natively in Word, except in the OUTLINE view. You might want to take a look at that before you invest a lot of time and effort.

    The only way to "hide" things in Word is to make the font hidden (or actually delete it from the document).

    An efficient way to do this is to format the text that has to be turned on/off with a particular style and change the Font.Hidden property of the style, as required.

    But it would also be possible to do this for any specific (bookmark) Range.

    What to use for a button: this could be an ActiveX control (Forms 2.0 library) or a MacroButton field code. The one can be set to "float" on its own, the other would have to be placed in a frame or textbox.


    Cindy Meister, VSTO/Word MVP
    Tuesday, June 21, 2011 4:41 PM
    Moderator
  • Well, I know it is not supported natively in Word (I actually sit on the Office Global Consumer Escalation Team but we don't support code so I don't get much opportunity to work with it).

    I was hoping to achieve it with code.

     

    I don't like the Outline View for this purpose becuase inserted objects and pictures rae not shown.

     

    Hiding/unhiding the text is an interesting option except that I was hoping for the document to expand/contract such that sections below the the expanding/contracting section actuially move up or down (similar to expanding or contracting groups in Excel).

     

    Tuesday, June 21, 2011 5:30 PM
  • <<Hiding/unhiding the text is an interesting option except that I was hoping for the document to expand/contract such that sections below the the expanding/contracting section actuially move up or down (similar to expanding or contracting groups in Excel).>>

    If you hide text then the following text "moves up". This assumes, of course, that you have the display of hidden text deactivated.


    Cindy Meister, VSTO/Word MVP
    Wednesday, June 22, 2011 12:48 PM
    Moderator