Hiding Document Sections

W

Word Heretic

G'day "p horrigan" <[email protected]>,

its a font property

p horrigan said:
Does anyone know how to hide/unhide sections of a Word Document using VBA?

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
J

JGM

Hi p,

What Steve means is something like this:

This will toggle the current section beteween hidden and not hidden:

ActiveDocument.Bookmarks("\Section").Range.Font.Hidden = _
Not ActiveDocument.Bookmarks("\Section").Range.Font.Hidden

or, with the Selection object you achieve the same result:

Selection.Sections(1).Range.Font.Hidden = _
Not Selection.Sections(1).Range.Font.Hidden

If you want a particular section, without necessarily selecting it:

This will toggle section #2:
ActiveDocument.Section(2).Range.Font.Hidden = _
Not ActiveDocument.Section(2).Range.Font.Hidden

HTH
Cheers!
 
W

Word Heretic

G'day "JGM" <[email protected]>,

Thats the one :)

JGM said:
Hi p,

What Steve means is something like this:

This will toggle the current section beteween hidden and not hidden:

ActiveDocument.Bookmarks("\Section").Range.Font.Hidden = _
Not ActiveDocument.Bookmarks("\Section").Range.Font.Hidden

or, with the Selection object you achieve the same result:

Selection.Sections(1).Range.Font.Hidden = _
Not Selection.Sections(1).Range.Font.Hidden

If you want a particular section, without necessarily selecting it:

This will toggle section #2:
ActiveDocument.Section(2).Range.Font.Hidden = _
Not ActiveDocument.Section(2).Range.Font.Hidden

HTH
Cheers!

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top