Consulting

Results 1 to 4 of 4

Thread: Problems with Header/Footer after inserting a file

  1. #1
    VBAX Newbie
    Joined
    Oct 2005
    Posts
    2
    Location

    Question Problems with Header/Footer after inserting a file

    Greetings,

    I have a template that when i insert certain files that already have a header or footer insert themselves and override my document. Im not very experienced with either the header or footer part of a word document so please pardon my laim attempts.

    Here is the process.

    The user inserts a file.

    Later on the user runs code to get rid of any header or footer information.

    Sub KillHeadersFooters()
    Dim oSection As Section
    Dim oHeadFoot As HeaderFooter
    For Each oSection In ActiveDocument.Sections
    For Each oHeadFoot In oSection.Footers
    If Not oHeadFoot.LinkToPrevious Then oHeadFoot.Range.Delete
    Next
    Next
    For Each oSection In ActiveDocument.Sections
    For Each oHeadFoot In oSection.Headers
    If Not oHeadFoot.LinkToPrevious Then oHeadFoot.Range.Delete
    Next
    Next

    End Sub

    Then I try and have the user run this code to reinsert page numbers into the entire document

    Sub InsertPageNum()
    Selection.Sections(1).Footers(1).PageNumbers.Add PageNumberAlignment:= _
    wdAlignPageNumberCenter, FirstPage:=False
    End Sub

    But nothing happens to the document.

    Please help


  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Does the document (with the inserted file) only have one section?

    Does anything have Different first page, or Different Odd/Even header or footer?

  3. #3
    VBAX Newbie
    Joined
    Oct 2005
    Posts
    2
    Location
    To be truthfull im not sure. When i do a search on the document that is problematic i find only one. And its at the top of the page.

    Why is it when i use the above code that i can no longer either manually or VBA insert another page number at the bottom of my doc?

    Thoughts?

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Huh? At the top of the page???? Uh, what were you searching for? I am not sure what you found.

    Your code for insert page number has FirstPage = False. This is an explicit nstruction to NOT use page numbering on the first page.

    How many pages are in the document?

    Please check File > Page Setup and check for Different first page, Different Odd/Even.

    Do you have Show/Hide ON? If not, please turn it on, and then look for Section breaks.

    I can certainly manually put in page numbers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •