Cannot get Word 2002 to Repaginate

J

Jamie Carper

Help Please!

According to all the documentation I can find,
ActiveDocument.Repaginate should be the ticket. But I cannot get
Repaginate to work.

I have a document that says on the footer of the very last page, "Page
8 of 7".
wdActiveEndPageNumber returns 8 as does wdNumberOfPagesInDocument. But
everytime I call the method ActiveDocument.Repaginate the page numbers
remain incorrect.

I have searched high and low for an answer and only found others
complaining about similar pagination problems and no one has the
answer. Tried looking up Repagination on MSDN, got zilch other than
the VBA Help page for that method.

I hope you can help,

Jamie
 
J

Jay Freedman

Hi, Jamie,

I think you'll find that Word is repaginating (figuring out where the page
breaks go) just fine, but what's really happening is that the NUMPAGES field
in the footer isn't being updated (because field updating isn't a function
of repagination). Try adding this to the end of the macro:

Dim oSec As Section
For Each oSec In ActiveDocument.Sections
oSec.Footers(wdHeaderFooterPrimary) _
.Range.Fields.Update
Next oSec

Alternatively, if the Update Fields option is checked in Tools > Options >
Print, you can just flip into and out of Print Preview like this:

With ActiveDocument.ActiveWindow.View
.Type = wdPrintPreview
.Type = wdPrintView
End With
 

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