Macro for headers and footers

Please can anyone help.    I use a macro which makes the document into book fold and landscape paper.  The document has a different first page header and footer.  In just some cases when I use my macro, it ignores the fact that I have a different first page header and footer.  I thought I could put a line into the macro that would fix this when it happeneds  I have recorded a macro to insert into this macro, but it does not seem to make any difference. The first page should not have a line in the header or footer, but in some instances it puts it in there ?  Could anyone help please.

If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
        ActivePane.View.Type = wdOutlineView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

Show us the whole macro.

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

2 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

The macro you posted just takes you into the header and then back out to the main document without doing anything.

When you have a different first page, your macro must process both the ordinary headers found on the second and subsequent pages, plus the first page header. Here is typical header/footer code (not directly relevant to your project, just used as an illustration):

  Dim aSection As Section
  For Each aSection In ActiveDocument.Sections
    With aSection
    .Footers(wdHeaderFooterPrimary).Range.Bookmarks("Disclaimer").Range.Font.Hidden = False  'shows bookmarked range
      .Footers(wdHeaderFooterFirstPage).Range.InlineShapes(1).Range.Font.Hidden = True  'hides in-line graphics. In-line graphics cannot be named
      .Headers(wdHeaderFooterFirstPage).Shapes("LogoPage1").Visible = True  'shows a named graphics
    End With
    With ActiveDocument
        .Bookmarks("CompanyName").Range.Font.Hidden = False
        .Bookmarks("Address1").Range.Font.Hidden = False
        .Bookmarks("Address2").Range.Font.Hidden = False
        .Bookmarks("Phone").Range.Font.Hidden = False
    End With
  Next aSection

The first Footer command is for an action on the main footer, the one that appears on page 2 and later. The second Footer command is for an action on the first page footer, which is a separate object. Then the third command applies to the first page Header, yet another object. As you can see, programming the header and footer can get a little complicated!

As Doug suggests, please post the whole macro and we'll get it straightened out for you.

Author of "OOXML Hacking - Unlocking Microsoft Office's Secrets", ebook now out
John Korchok, Production Manager
production@brandwares.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

THANK YOU, so very much, thats perfect, I am very grateful.

Margaret

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 1,778 Applies to: