View Single Post
 
Old 06-11-2021, 12:26 AM
Nik0 Nik0 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Jun 2021
Posts: 1
Nik0 is on a distinguished road
Default

Well, I solved that task (To get header text from each/selected page) in simple way (it works in my case):
Code:
Function GetPageHeader(MyCurrentPage As Integer) As String
    Set sel = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=mCPage)
    GetPageHeader = ActiveDocument.Range.GoTo(What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=MyCurrentPage).Sections(1).Headers(wdHeaderFooterPrimary).Range.Text
End Function
We just go to needed page (by Count:=MyCurrentPage) ang get it's first section's "PrimaHeader".
Well, we may have problems with section amount or correct number, but you can just loop it.
Selection.GoTo - helps in cases where you keep getting wrong (general) header.
Reply With Quote