Programing the page number

J

juan

Hello:
I have an application of Visual Basic 2005. I can make a word XP document
("Document 1") by code inside the application. I want to put the page number
in the document but I don't know how from inside the code of Visual Basic.
That's the problem.
Thanks
 
D

Doug Robbins - Word MVP

The best thing to do would be to create the document from a template that
already has the page number set up in it in the position that you want it.

However, the following code will add a { PAGE } field to the primary footer
of the first section in a document.

Dim frange As Range
With ActiveDocument
Set frange = .Sections(1).Footers(wdHeaderFooterPrimary).Range
.Fields.Add frange, wdFieldEmpty, "Page"
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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