Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2021, 02:03 AM
SamDsouza SamDsouza is offline Return Page Number of Paragraph Number Windows 10 Return Page Number of Paragraph Number Office 2013
Advanced Beginner
Return Page Number of Paragraph Number
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default Return Page Number of Paragraph Number

Hello
Any ideas if i want to know the Page No of which Para Number Exists. I am unable to find any thread of the same. Niether i am unable to fine syntax it.
Because
Determining the Current Page Number (Microsoft Word)
mentions as below
Quote:
As you are programming your macros, you may have a need to know the current page number on which the insertion point is located. This is easily obtained by using either of the following code lines in your macro:

CurPage = Selection.Information(wdActiveEndAdjustedPageNumbe r)
CurPage = Selection.Information(wdActiveEndPageNumber)



This code sets CurPage to the current page number. If you use the form containing wdActiveEndAdjustedPageNumber, then CurPage is a logical page number, not a physical page number. The difference is that logical page numbers take into account manual adjustments that may have been made to the document. For instance, if the user instructed Word to start counting pages at some value other than 1.
So instead of Selection.Information
By Using .Paragraphs(txtParaNo.Text) I want to get its Page Number.

Code:
dim i as integer

With ActiveDocument
For i = 1 to .Range.Paragraphs.Count
    With .Paragraphs(i)

    End with   
Next
End with
SamD
Reply With Quote
  #2  
Old 03-04-2021, 02:25 AM
gmayor's Avatar
gmayor gmayor is offline Return Page Number of Paragraph Number Windows 10 Return Page Number of Paragraph Number Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You could use a function to get the page number of any paragraph you supply it with e.g.
Code:
Function PageNum(iPara As Integer) As Integer
    With ActiveDocument
        With .Paragraphs(iPara).Range
            PageNum = .Information(wdActiveEndPageNumber)
        End With
    End With
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 03-04-2021, 04:52 AM
SamDsouza SamDsouza is offline Return Page Number of Paragraph Number Windows 10 Return Page Number of Paragraph Number Office 2013
Advanced Beginner
Return Page Number of Paragraph Number
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Thank you very much Sir,

Great Function

Now i got myself very clear on the Right Syntax ie

ActiveDocument.Paragraphs(2).Range.Information(wdA ctiveEndPageNumber)

A Last question on this thread

For eg lets say a Paragraph(6) is at the End Of (EO) Page 1 and Continues to next Page 2. ie 2 - 3 lines of Para(6) EO pg1 and 5 - 6 lines BO Pg2
Your function shall result as What and Why ?

SamD
Reply With Quote
  #4  
Old 03-04-2021, 05:03 AM
gmayor's Avatar
gmayor gmayor is offline Return Page Number of Paragraph Number Windows 10 Return Page Number of Paragraph Number Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It will show page 2 - the clue is in the information sought by the function.
If you want the page number it starts on then collapse the range to its start before asking the question e.g.
Code:
Dim iStart As Integer, iEnd As Integer
    With Selection.Paragraphs(1).Range
        iEnd = .Information(wdActiveEndPageNumber)
        .Collapse 1
        iStart = .Information(wdActiveEndPageNumber)
        MsgBox "Starts on page " & iStart & vbCr & "Ends on page " & iEnd
    End With
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 03-04-2021, 09:37 PM
SamDsouza SamDsouza is offline Return Page Number of Paragraph Number Windows 10 Return Page Number of Paragraph Number Office 2013
Advanced Beginner
Return Page Number of Paragraph Number
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Thank you sir for the clarification and indeed a valuable input of .Collapse
SamD
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return as many Y as the number of occurrence of values in another column Marcia Excel 2 11-27-2020 04:19 PM
Table of content to include a page number comprising Section and page number Allen001 Word 2 11-25-2019 05:38 AM
Excel Match return different row number kimak Excel 1 03-01-2017 09:39 AM
Return Page Number of Paragraph Number How do I create a field that will return the current paragraph number minus one in an automatic list gugootz Word 1 11-23-2015 04:58 PM
Page number with chapter number but not from Heading 1 alpruett Word 5 06-04-2014 02:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:00 AM.


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