Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2016, 07:01 AM
gmayor's Avatar
gmayor gmayor is offline Find out if Page of Heading 1 has header Windows 10 Find out if Page of Heading 1 has header Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default


The first page header will exist, even if empty, provided the different first page option is applied to the current section. I suspect what you want is to ensure the first page header has no content. In that case simply deleting the content of the header will achieve the aim of having an empty header e.g. as follows. I have added optional code to show if the header is empty.
Code:
Sub ClearHeader()
Dim secTemp As Section
Dim sectionNum As Integer
Dim oHeader As HeaderFooter
    sectionNum = Selection.Information(wdActiveEndSectionNumber)
    Set secTemp = ActiveDocument.Sections(sectionNum)

    If secTemp.Headers(wdHeaderFooterFirstPage).Exists = True Then
        Set oHeader = secTemp.Headers(wdHeaderFooterFirstPage)
        If Len(oHeader.Range) > 1 Then 'Optional
            oHeader.Range.Delete
        Else 'optional
            MsgBox "Header is empty" 'optional
        End If 'Optional
    End If
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #2  
Old 02-10-2016, 01:13 PM
rocky2 rocky2 is offline Find out if Page of Heading 1 has header Windows 10 Find out if Page of Heading 1 has header Office 2013
Novice
Find out if Page of Heading 1 has header
 
Join Date: Feb 2016
Posts: 25
rocky2 is on a distinguished road
Smile Thanks!

Thanks. It worked.
Reply With Quote
  #3  
Old 02-10-2016, 09:44 PM
rocky2 rocky2 is offline Find out if Page of Heading 1 has header Windows 10 Find out if Page of Heading 1 has header Office 2013
Novice
Find out if Page of Heading 1 has header
 
Join Date: Feb 2016
Posts: 25
rocky2 is on a distinguished road
Default One more question - hierarcy for the header text seems deeper

It did work once. But then, it was empty and to get to the header text I had to go to:
oHeader.Range.Sections.First.Headers.Item(1).Range .Text

does that make sense?
Is there a more "proper" way to get to this info or at least to Item(1)?
Reply With Quote
Reply

Tags
headers, heading 1, section breaks



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find out if Page of Heading 1 has header Can't remove page break between a Heading 1 and a Heading 2 Nathan8752 Word 3 08-31-2015 12:41 PM
Find out if Page of Heading 1 has header Can I unter the last heading in a footer, regardless of what level the header is? Huffle Word 2 09-28-2014 03:48 PM
include heading text in header eNGiNe Word 2 03-06-2013 12:24 AM
How to have a heading 1 file automatically appear in each header of any page? expert4knowledge Word 2 09-16-2012 10:38 AM
Find out if Page of Heading 1 has header Need to change text in header to next Heading 1 Kanith Word 1 06-14-2011 03:35 PM

Other Forums: Access Forums

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