Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #26  
Old 02-08-2019, 12:47 AM
BeginnerLearner BeginnerLearner is offline How to get all headers text in a Word Document ? Windows 10 How to get all headers text in a Word Document ? Office 2013
Novice
How to get all headers text in a Word Document ?
 
Join Date: Feb 2019
Posts: 22
BeginnerLearner is on a distinguished road
Default

Hi, macropod

Do you know other ways to get all headers from the word document?

At first, I wanted to go through the word document using page by page. However, I have searched online and found out that I can't do that as Word is not a page layout software.

I have also tried using StoryRanges.

Code:
Sub getHeader()

Dim oStory As Range
MakeHValid
For Each oStory In ActiveDocument.StoryRanges
    Do
        If oStory.StoryType = wdPrimaryHeaderStory Then
            MsgBox "There is a header"
            MsgBox oStory
        End If
        Get next linked story
        Set oStory = oStory.NextStoryRange
        Loop Until oStory Is Nothing
        Next

End Sub

Public Sub MakeHValid()
Dim lngjunk As Long
lngjunk = ActiveDocument.Range.StoryType
End Sub
Code:
MsgBox ActiveDocument.StoryRanges(wdPrimaryHeaderStory)
However, it did not work. The second code only gives me one of the headers text.

Thus, I am thinking if there is any way to get all the headers.

Thank you for your help
Reply With Quote
 

Thread Tools
Display Modes


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 03:38 PM.


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