Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    May 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Footers/Same As Previous (VBA/MSWord/2000)

    Hi there,

    I'm finding with a document where there is more than one section to begin with, then I add a new section at the top of the document and go on to try to switch off the same as previous feature in the footer of section two, the feature remains true for that section, however, becomes false in the footer of section 3. See below:

    Selection.InsertBreak Type:=wdSectionBreakNextPage
    Selection.GoTo What:=wdGoToSection, Count:=2
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.HeaderFooter.LinkToPrevious = False 'this command successfully turns off same as previous for page header
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    Selection.GoTo What:=wdGoToSection, Count:=2
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Selection.HeaderFooter.LinkToPrevious = False 'this command incorrectly turns off same as previous for page footer on section 3 rather than section 2

    Hope this makes sense and thanks in anticipation.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Footers/Same As Previous (English/MSWord/2000)

    The way section breaks work in Word is sometimes hard to follow. This is one of the instances where executing a recorded macro does not have the same effect as the actions you recorded. The "solution" is to refer explicitly to the header/footer of the second section, instead of changing the view:

    Selection.InsertBreak Type:=wdSectionBreakNextPage
    ActiveDocument.Sections(2).Headers(wdHeaderFooterP rimary).LinkToPrevious = False
    ActiveDocument.Sections(2).Footers(wdHeaderFooterP rimary).LinkToPrevious = False

  3. #3
    New Lounger
    Join Date
    May 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Footers/Same As Previous (English/MSWord/2000)

    HansV,

    You are fast becoming my hero, thank you so much!

  4. #4
    New Lounger
    Join Date
    May 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Footers/Same As Previous (English/MSWord/2000)

    I've now come up against another problem with my macros - my document's last section is a blank last page where the footer is NOT same as previous and is completely blank. The footers in the previous sections of the document all have page numbers, file and pathname details and the date. (Example attached.)

    I need to remove the blank page at end, however, when I do this by just deleting the section break, the footers in the previous sections also become blank. I thought I could perhaps just turn on Same as Previous for the footer of the last section (i.e., the blank page) before I delete it, however, I'm not having much luck working out the code!

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Footers/Same As Previous (English/MSWord/2000)

    This is a bit of a kludge, perhaps someone else will come up with a better method:

    With ActiveDocument.Sections(ActiveDocument.Sections.Co unt)
    .Footers(wdHeaderFooterPrimary).LinkToPrevious = True
    .Range.Delete
    End With
    Selection.EndKey Unit:=wdStory
    With Selection.Find
    .ClearFormatting
    .Text = "^b"
    .Forward = False
    .Execute
    End With
    Selection.Delete

  6. #6
    New Lounger
    Join Date
    May 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Footers/Same As Previous (English/MSWord/2000)

    Kludge or no kludge, it does the trick - once again, thank you so much!

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Footers/Same As Previous (English/MSWord/2000)

    I think we've previously discussed the need for a "general" delete-next-section macro that takes account of all the section-specific settings (including the Page Setup dialog settings). I can't remember whether Phil posted one, or he was just sharing my lament. Anyway, if you realize that anything else is different about your last section, you could add that to Hans' macro.

Posting Permissions

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