D
Derek Hart
I am running the following code to try to update and unlink page number
fields. Very inconsistent results are happening. Sometimes it works;
sometimes it updates all the page numbers to 1; sometimes it updates all the
page numbers to 1 except the last page number is correct. What is the right
way to do this? I want to unlink the field and save the file.
Dim oSec As Section
For Each oSec In ActiveDocument.Sections
oSec.Range.Collapse wdCollapseEnd
With oSec.Range.Fields
.Update
.Unlink
End With
With oSec.Headers(wdHeaderFooterPrimary).Range.Fields
oSec.Range.Collapse wdCollapseEnd
.Update
.Unlink
End With
With oSec.Footers(wdHeaderFooterPrimary).Range.Fields
oSec.Range.Collapse wdCollapseEnd
.Update
.Unlink
End With
Next
Derek
fields. Very inconsistent results are happening. Sometimes it works;
sometimes it updates all the page numbers to 1; sometimes it updates all the
page numbers to 1 except the last page number is correct. What is the right
way to do this? I want to unlink the field and save the file.
Dim oSec As Section
For Each oSec In ActiveDocument.Sections
oSec.Range.Collapse wdCollapseEnd
With oSec.Range.Fields
.Update
.Unlink
End With
With oSec.Headers(wdHeaderFooterPrimary).Range.Fields
oSec.Range.Collapse wdCollapseEnd
.Update
.Unlink
End With
With oSec.Footers(wdHeaderFooterPrimary).Range.Fields
oSec.Range.Collapse wdCollapseEnd
.Update
.Unlink
End With
Next
Derek