how can I delete an entire section

  • Thread starter Thread starter Keith G Hicks
  • Start date Start date
K

Keith G Hicks

word 03
access 2k

I need to programatically delete an entire section from a document in the
event that section does not apply to a customer. How would I do this in vba?

Thanks,

Keith
 
I should make it clear that I want to delete the whole section - content,
headers, footers, etc. - not just the section break.

Keith
 
This is not nearly as straightforward as you might think. The difficulty is
that the section-level formatting (margins, headers/footers, columns, paper
sources, etc.) is stored in the section mark at the _end_ of the section.
The article http://www.word.mvps.org/FAQs/Formatting/WorkWithSections.htm
explains some of the hiccups you can run into by deleting a section break.

In code, you can run the command

wordDoc.Sections(N).Range.Delete

but the effects will be different depending on whether the Nth section is
the last one in the document. You may also need to adjust the formatting and
the content of the headers in the following section(s).

It might be more effective to set the entire section to the Hidden font
format rather than deleting it.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
This is easiest to do in Normal view. Select all the text from just after
the section break that begins the section up to and including the section
break that ends the section. Press Delete.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Back
Top