Hello, Greeting to Everyone
While setting/adjusting the pagenumbers via VBA or pywin (python) the first page header gets expand which distrupts the formatting of every other pages.
Here is the code recorded from word
Code:
Sub AdjustpageNumbers()
With Selection.Sections(1).Headers(1).PageNumbers
.NumberStyle = wdPageNumberStyleArabic
.HeadingLevelForChapter = 0
.IncludeChapterNumber = False
.ChapterPageSeparator = wdSeparatorHyphen
.RestartNumberingAtSection = True
.StartingNumber = 84
End With
End Sub
If we adjust the pagenumber manually the problem doesn't exist. But if we attempt it with code the first page header will be expanded and a paragraph will appear. Is there a way to change the page numbers without causing expansion of Header in the first page?
I have attached the snipped images of before and after running the code. Please have a look.
first page does not have a page number (header) because the document is set to
Different First page = True
and
Different odd and even page = True
The main concern is that I have defined some functions that continue page numbers in multiple documents. But in some cases, the function returns wrong page numbers because whenever the function to set a new page number is called or if the header is accessed through the code, an extra paragraph is appears in the first page of the document which causes all the following pages to overflow. Hence, returning the false page number (in most cases total page + 1).
I wanted to know if this could be avoided. Or if i am doing anything wrong.