Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #31  
Old 02-08-2019, 01:11 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: 21,956
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

If you did as I suggested in post #17, you wouldn't need to check the document as you could be assured the header would reflect the cover page.



And yes, you can save a Style. I'd have thought that was perfectly obvious as the attachment to post #17 has two such Styles being used for this. Simply add them to your exam document's template.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #32  
Old 02-08-2019, 07:37 PM
Guessed's Avatar
Guessed Guessed 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 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Are you trying to automate the marking of exam papers OR trying to identify problems in exam papers you are creating?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #33  
Old 02-09-2019, 02:21 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, Guessed

When the teachers created the exam paper, sometime there will be errors like incorrect total marks, missing pages or questions. Thus when we open the document using the program that I am doing in UiPath, the program will automate the workflow and check if the exam paper has any errors. The errors identified will be written in a text file.
Reply With Quote
  #34  
Old 02-09-2019, 02:24 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, I will try it out and get back to you.

Thank you
Reply With Quote
  #35  
Old 02-09-2019, 04:12 AM
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: 21,956
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
When the teachers created the exam paper, sometime there will be errors like incorrect total marks, missing pages or questions.
Getting the headers isn't going to tell you any of those things. It won't even tell you if there are missing pages because, except for your first page, all pages will have the same header.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #36  
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
  #37  
Old 06-11-2021, 06:36 AM
macropod's Avatar
macropod macropod 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 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

There are far easier ways to do what your code does, but it doesn't do what you think it does - all it does is get the primary header for the current Section (not the current page header). What your code clearly doesn't do is retrieve what might be a 'first page' or 'even page' header when that's what might be displayed for the selected page.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

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 11:55 PM.


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