Question

I have a VBA macro that cleans a 2010 Word document. Actually, it removes empty rows on many tables.

At the end of the function, I would like to create a table of contents with the titles and page numbers of all tables in the document.

Dim tTable As Table
tTable.Range.Information(wdActiveEndPageNumber)

The problem is, cleaning the tables reduced the length of the document from 30 pages to 25 pages. When I call .Information(wdActiveEndPageNumber) the page indexes have not been updated yet.

I tried to call Sleep for a while but it doesn't work either.

I'm not a VBA specialist, but is there a function to force update the page numbers of a document?

Thanks

Was it helpful?

Solution

After some research, I found the function to call:

ActiveDocument.Repaginate

It seems to work fine!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top