Don't use a macro for this.
Work with headers and footers and fields. Learn this first, before you start
messing with macros. Unless you understand what you are trying to get Word
to do, macros just let you mess up your document faster and more thoroughly!
You want to have each new section restart page numbering.
Make sure your fields are inserted with real field delimeters like those
inserted using Ctrl-F9 and not typed in.
If you are showing {page} then either you do not have proper delimiters or
you are displaying field codes. The underneath page 1 of 1 tells me that you
probably are not displaying field codes.
Start with a brand new document. Put some text in it by typing exactly what
is below and then pressing the enter key.
=Rand(30,7)
At the end of the document, insert a break with a next page section break.
Type the text formula again except use 90 instead of 30. You should now have
a multi-page document with two sections of different size.
Now go into headers and footers.
Format your page numbers using the button for this on the toolbar so that
the page numbers restart.
Type the following:
Page page of SectionPages
Select "page" and press Ctrl-F9. Press F9.
Select "SectionPages" and press Ctrl-F9. Press F9.
You have your header. The two sections should show the lengths of the
sections.
Close the header/footer view. Delete all the text. Save this as a template
and use it as the start for your compilation documents.
From now on, when you insert a section break at the end of the document
created from this template, you will end up with your page numbering
restarting and reflecting the contents of your section in your header.
Ctrl-End takes you to the end of a document. Now, if you really need a
macro, start from that point.
The following macro goes to the end of a document, inserts a next page
section break and pastes text.
Sub BreakAndPaste()
'
' Macro written 20 Dec 2005 by Charles Kyle Kenyon
'
Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.PasteAndFormat (wdPasteDefault)
End Sub
Inserting fields or altering headers/footers using a macro complicates
things immensely. Unless I see a reason for you to do this, I don't care to
spend my time helping you do it.
--
Charles Kenyon
Word New User FAQ & Web Directory:
http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
http://addbalance.com/usersguide
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.