My code goes through a folder of documents and deletes a section from each. Sometimes, particularly when Track Changes are on, an unwanted byproduct is a blank page. Accept the changes, and the blank page goes away. I want to keep track of the documents where this happens through these steps:
1. Save the document
2. Get a page count
3. Accept all changes
4. Get a second page count
5. Close without saving
6. Compare the two page counts
Problem: The first page count is often short, I think because the document is still repaginating when I get the count. Here's my latest version of my code, where the idea was to delay further processing until the repagination command completes with an accurate page count (it didn't work):
Any ideas?
1. Save the document
2. Get a page count
3. Accept all changes
4. Get a second page count
5. Close without saving
6. Compare the two page counts
Problem: The first page count is often short, I think because the document is still repaginating when I get the count. Here's my latest version of my code, where the idea was to delay further processing until the repagination command completes with an accurate page count (it didn't work):
Code:
ActiveDocument.SaveAs FileName:=rplc_dir & "\" & file_name
ActiveDocument.Repaginate
pgs_chgs_trckd = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
WordBasic.AcceptAllChangesInDoc
ActiveDocument.Repaginate
pgs_chgs_acptd = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
Debug.Print file_name & " (" & "tracked: " & pgs_chgs_trckd & ", accepted: " & pgs_chgs_acptd & ")"
If pgs_chgs_trckd <> pgs_chgs_acptd Then
...
Any ideas?