Shauna
Fri Jan 11 17:36:10 PST 2008
Hi Marie
Strictly speaking, you can't delete a section. You can only delete its
.Range:
The section's .Range includes the section break at the end of the
section which holds the section's properties, including its headers and
footers. So, as an example, you could have a document with three
sections, the middle one of which is landscape. The following code would
delete the content within the second section and the section break
following it, leaving two sections, both portrait:
Sub DeleteSection2()
Dim oSec As Word.Section
Set oSec = ActiveDocument.Sections(2)
oSec.Range.Delete
End Sub
I'm not aware of "the header and footer problem that occurs when
deleting section breaks". I find Word's behaviour to be consistent: when
you delete the .Range of a section, Word deletes the section's headers
and footers, which is what I would expect.
If that does not suit your particular business needs, you may need to
make adjustments.
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
"MarieJ" <MarieJ@discussions.microsoft.com> wrote in message
news:0122DCD9-EF50-4B8E-8069-B5F8E612EABB@microsoft.com...
> Hi,
> I'm looking for a macro that deletes the current section in a
> multi-section
> document, and that fixes the header and footer problem that occurs
> when
> deleting section breaks. I wanted to find out if someone had a macro
> out
> there already before I tackled it myself.
> TIA
> MarieJ