Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need macro to remove "Link to Previous" in Header

Status
Not open for further replies.

fishey

Instructor
Oct 30, 2002
24
US
I have recorded the keystrokes to: (i) insert a section break on next page, (ii) go into the first page header of the new section, (iii) unlink the header to the previous header, (iv) delete all text in current header, and (v) close the header.

However, when I go to play back the macro, the new section's header is still linked to the previous header so that when I delete its text, the previous header's text is deleted as well. Here is the code:

Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakNextPage

'remove "link to previous" and text of header:
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.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

 
Hey,

Yer name sure sounds fishhhhhhhhhh......

A shucks! I just cundn't resist! ;-)

Try replacing the text delete with
Code:
ActiveDocument.Sections(ActiveDocument.Sections.Count).Headers(wdHeaderFooterPrimary).Range.Text = &quot;&quot;
:)

Skip,
Skip@TheOfficeExperts.com
 
Skip, this worked like a charm! (The reason it took me so long to respond to you is that I didn't receive an e-mail notification that a response had been made to my initial request. I just checked this thread manually today and was THRILLED to see you had replied.)

Thanks so much for your assistance, Skip (in spite of the wisecracks about my name!)

Sincerely,
&quot;fishey&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top