Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-18-2024, 02:49 AM
Bikram Bikram is offline Setting page numbers Windows 10 Setting page numbers Office 2007
Advanced Beginner
Setting page numbers
 
Join Date: Jul 2021
Location: Nepal
Posts: 94
Bikram is on a distinguished road
Default Setting page numbers

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.
Attached Images
File Type: png 0.png (11.6 KB, 21 views)
File Type: png after.png (12.5 KB, 21 views)
Reply With Quote
 

Tags
setting page numbers

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Even page numbers disappear when setting up opposite headers. slromine Word 2 08-02-2019 08:05 AM
Setting page numbers Footer for page numbers recently started showing a colored field when adding page numbers thefonebug Word 12 10-24-2016 05:18 AM
How do I edit my TOC to reference the section numbers instead of the page numbers??? mikey386 Word 0 12-17-2014 02:34 PM
How do I refer to page numbers, when the numbers change as I prepare the document? StevenD Word 5 11-29-2012 12:52 AM
Setting page numbers Page Numbers Not Matching Chapter Numbers gracie5290 Word 1 02-02-2012 11:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:08 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft