Macro to create section

D

Daniel

Hello,

I'm hoping someone might be able to "donate" some code for two seperate
case:

1- Create a page after the last page in the document wish would be in a new
section.
2- Change the page setup of the current document so that the current page
would be the start of a new section

Thanks for the help. I'm having a really hard time programming anything to
do with section management?!

Daniel
 
S

Sabaka

Sub AddSect()
'add a new section at end of document
Dim char As Range
'set char to the last character in the document
Set char = ActiveDocument.Range.Characters.Last
'With sections collection object, use add method to add a section
ActiveDocument.Sections.Add Range:=char
End Sub
 
S

Sabaka

About your second question, what do you mean by "current page"? My
understanding is that Word isn't really designed around pages. As I
understand it, Word sees a document as a collection of sections, ranges,
paragraphs and characters. If the "current page" is just the one where the
cursor is blinking, then why not just use the insert menu to insert a break
at the cursor? If the current page is something else, I think you need to
define it in terms of a range or a section or something Word understands.
 
D

Daniel

Sabaka,

After testing the code you gave me, I have one more request to ask of
you. Could you illustrate how I can insert a section but having a different
header and footer than the previous section?

Thank you once again,

Daniel
 

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