Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-07-2019, 07:35 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



Thank you for your explanation, now I get it

Sorry I have last 2 questions.

What if instead of checking if the words are exactly the same, we check if the words are similar? Will this cause a problem?

Instead of using sections, can I check page by page?

Thank you
Reply With Quote
  #2  
Old 02-07-2019, 01:08 PM
macropod's Avatar
macropod macropod 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 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,523
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by BeginnerLearner View Post
What if instead of checking if the words are exactly the same, we check if the words are similar? Will this cause a problem?
It's exactly the same problem.

Quote:
Originally Posted by BeginnerLearner View Post
Instead of using sections, can I check page by page?
I can't see what Sections has to do with this - your example document still only has one Section. Regardless, for a multi-Section document, all you'd be doing is repeating the same comparison issue for every Section.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
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
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:10 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