Manipulate Headers/Footer in new Sections


Joined
Sep 3, 2013
Messages
1
Reaction score
0
Good Morning!

I'm new here and I'm hoping for help with which turned to be a hairy problem for me. I have to design a template for our Account Managers. User computer skill has be assumed to be zero. Saying that, I'm always surprised to what extent people like that can mess up a document!

I have now been asked to insert our Terms & conditions into the document and pdf it. Legal won't allow the Terms to be present in Word form in the document when it is opened (for obvious reasons, also see above). So the idea is to

  • insert a new section
  • set the header/footing settings for this section to a) have a different first page header and b) NOT link to the previous header/footer
  • change header and footer in both options (first page/others) - I was thinking of doing that with an AutoText
  • Insert Terms (again, I was going to save them as an AutoText

I have cobbled together some code but nothing so far remotely works. I only get to insert a new section. I found one way to insert the header but it leaves the exising paragraph mark which pushes my header too far up/down. And "ActiveDocument.Range.Select" actually selects the entire document and deletes everything. Oops.

Code:
Dim oDoc As Word.Document
Dim intCurPag As Integer
Dim myTemplate As Template

Set myTemplate = ActiveDocument.AttachedTemplate

    'Note: Current Page Number
    intCurPag = Selection.Information(wdActiveEndPageNumber)
    
    'Note: Insert Section Break Next Page, disable Link to Previous, Different First Page Header
    
    Dim myRng As Word.Range
    Set oDoc = ActiveDocument
        ActiveDocument.Bookmarks("BM_TC_Warranty2").Select
        Selection.InsertBreak Type:=wdSectionBreakNextPage
    
    ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
    'Note: Get the index number of the added section
    i = oDoc.Range(0, Selection.Sections(1).Range.End).Sections.Count
        With oDoc.Sections(i)
        For j = 1 To 3
            .Headers(j).LinkToPrevious = False
        .Footers(j).LinkToPrevious = False
        Next j
            End With
    'Note: j provides the constant value to unlink all three header\footer types.


    'Note: Insert Header (First Page Header = AutoText Header_GE_18)
    oDoc.ActiveWindow.ActivePane.View.Type = wdPageView
    oDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    
    'Note: Add AutoText
    ActiveDocument.Range.Select
    myTemplate.BuildingBlockEntries("Header_GE_18").Insert Where:=Selection.Range, RichText:=True

I need to do the whole thing twice (Terms, Warranty Conditions) so my code abobe is trying to break the "Link to Previous" for all sections. - I was going to put that code into the same Sub as the one that will pdf the document so nobody can mess anything up from thereon in.

Any ideas? Headers/Footers have turned out to be trickier than I ever imagined!
Thanks for any help or pointers, Christine
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top