Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    London, United Kingdom
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Header Disconnect & Delete Text (2000)

    I have recorded a macro to insert a section break and disconnect the header from previous. I tried to get it to delete the text in the now disconnected section but it doesn't seem to work. I don't know VB so any suggestions would be gratefully recieved.

    Sub aaa()
    '
    ' aaa Macro
    ' Macro recorded 19/05/2004 by HettyB
    '
    Selection.InsertBreak Type:=wdSectionBreakNextPage
    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
    Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
    LinkToPrevious
    Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
    Selection.Delete Unit:=wdCharacter, Count:=1
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    End Sub

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

    Re: Header Disconnect & Delete Text (2000)

    Recorded macros can be very useful, but in this case, the generated code is not only convoluted, but doesn't do what you want. It deletes the first word in the header of the section before the break. Try this instead:

    Sub aaa()
    Selection.InsertBreak Type:=wdSectionBreakNextPage
    With Selection.Sections(1).Headers(wdHeaderFooterPrimar y)
    .LinkToPrevious = False
    .Range.Delete
    End With
    End Sub

    If you also have a first-page header and/or even-page header that is different from the standard one, you must treat those separately.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    London, United Kingdom
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Header Disconnect & Delete Text (2000)

    I worship at your feet. <img src=/S/starstruck.gif border=0 alt=starstruck width=15 height=15>

    This works great. We don't encourage different first page headers/footers. No one ever uses them properly and can't figure out what is going wrong when someone does.

Posting Permissions

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