Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2021, 12:26 AM
Nik0 Nik0 is offline How to get all headers text in a Word Document ? Windows 7 64bit How to get all headers text in a Word Document ? 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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apply template with headers/footers to an existing Word document Files qadeerahmed Word 5 05-08-2017 05:28 AM
Headers & Footers - Show Document Text Aprilann Word 6 04-13-2017 09:34 AM
How to get all headers text in a Word Document ? Word 2007 - different text for odd and even headers? JQP Word 4 10-09-2011 06:49 PM
How do I have headers and footers appear as regular text for the whole document? user908045 Word 0 03-13-2010 12:41 PM
Portrait & Landscape Headers in Same Word Document Coast331 Word 0 10-24-2009 02:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:59 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