adding a page number to a header

B

Bert

I want to add a page number to the end of the first line of a header. When
I do so manually using the normal Header and Footer dialog box in Word
(2003), it works just fine. When I use VBA, it seems to insert the page
number into a text box or some other similar shape, which throws of the
appearance of the line. The code I'm using is:
Selection.Sections(1).Headers(wdHeaderFooterPrimary).PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberRight

This document is multiple sections (chapters), each with its own header(s).

Any suggestions for inserting the page number without the text box?

Thanks,
Bert
 
A

Anne Troy

When I record a macro using the non-textbox method:

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage


When I record using the crappy textbox method:

Selection.HeaderFooter.PageNumbers.Add PageNumberAlignment:= _
wdAlignPageNumberRight, FirstPage:=True

Maybe you can get the difference between those two. :)
*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com
 

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