Page Number - Please Help!!

S

scorpion53061

I am tring to use the recorder to record a macro in Word 2003 that will
insert a page number like this:

Martens 1
on the next page it would say

Martens 2

but it will not seem to allow me to do so.

The best I can do is it seems to insert a "1".

Can anyone help with vba code?
 
M

macropod

Hi,

Perhaps the easiest way to do this is to use your vba code
to insert a pair of nested fields into the header or
footer so that you get a result like:
{ }
Then fill the part between the braces with:
QUOTE "Martens "
followed by another field insertion and filling the part
between the new pair of braces with:
PAGE
so that you end up with a pair of nested fields that look
like:
{QUOTE "Martens "{PAGE}}

That way, you only need to output the field once, and it
will automatically update with the correct page count for
each page.

Cheers
 
S

scorpion53061

HI macro,

Could you (please) show me a code sample of what you have described for the
header either online or here?
 
S

scorpion53061

Figured it out never mind.....

macropod said:
Hi,

Perhaps the easiest way to do this is to use your vba code
to insert a pair of nested fields into the header or
footer so that you get a result like:
{ }
Then fill the part between the braces with:
QUOTE "Martens "
followed by another field insertion and filling the part
between the new pair of braces with:
PAGE
so that you end up with a pair of nested fields that look
like:
{QUOTE "Martens "{PAGE}}

That way, you only need to output the field once, and it
will automatically update with the correct page count for
each page.

Cheers
 
P

pre

Try this:

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.TypeText Text:="Martens "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:="page"
 
S

scorpion53061

dude you are a genius!!!!

pre said:
Try this:

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.TypeText Text:="Martens "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:="page"
 
S

scorpion53061

Just a quick question so I can learn something.....

what is it about typing

Text="page" that made it understand we were looking for
a page number here.......
 
P

pre

The macro is setting an ordinary Text: Martins . Next it create a field
{page} which (when sorrunded by the correct parenthesises) will update and
show the actual page no.
 
S

scorpion53061

Thanks pre I learned something today.

Any more good header tutorials in word you know of online?
 
J

JGM

Hi Macropod,

Please, if you can spare the time, can you explain the use of the Quote
field.... Why is it useful in this case, or in general... Why have a field
that shows text that you can simply type without the field? I have never
properly understood the purpose of the QUOTE field... (Except when you need
plain text in the midle of another field that would not otherwise allow you
to do that, but in this particular case, we could type "Martens {PAGE}" and
it would produce the same thing... no?)

The only time I have used it is when I reproduced the relative cell
numbering in a table (When you need those very complicated nested fields...)

TIA
 

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