Selection.HeaderFooter.LinkToPrevious

D

Debra Ann

To shut off my link to previous for the current page and then the next page,
I did the following but it only shuts off the headers, not the footers. I
get the same code when I follow my keystrokes. Why is this nor working?

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = Not _
Selection.HeaderFooter.LinkToPrevious
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.HeaderFooter.LinkToPrevious = Not _
Selection.HeaderFooter.LinkToPrevious
ActiveWindow.ActivePane.View.NextHeaderFooter
Selection.HeaderFooter.LinkToPrevious = Not _
Selection.HeaderFooter.LinkToPrevious
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter.LinkToPrevious
ActiveWindow.ActivePane.View.PreviousHeaderFooter
 
D

Debra Ann

Okay, I found some help from Doug Robbins on a previous thread that used:

With Selection.Sections(1)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
End With

I could use this, but how do I tell it to do the current section and the
following section? Can you do With Selection.Sections(Current)?
 
J

Jean-Guy Marcil

Debra Ann was telling us:
Debra Ann nous racontait que :
Okay, I found some help from Doug Robbins on a previous thread that
used:

With Selection.Sections(1)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
End With

I could use this, but how do I tell it to do the current section and
the following section? Can you do With Selection.Sections(Current)?

Something like this (which also checks to make sure there is a section after
the currently active one):

'_______________________________________
Dim CurSecIndex As Long

CurSecIndex = Selection.Sections(1).Index

With ActiveDocument.Sections(CurSecIndex)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
End With

If CurSecIndex + 1 <= ActiveDocument.Sections.Count Then
With ActiveDocument.Sections(CurSecIndex + 1)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
End With
End If
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

Debra Ann

This worked awesome and solved two of my problems at the same time. I can't
thank you enough.

Thank you, thank you, thank you.
 
Z

zkid

This code used to work well in Word97. However, the subsequent versions have
made life a bit more difficult. This is a subroutine I use when I need to
insert a new section and I'm using different first page. If you aren't using
different first page, then just use the "primary" code You pass the current
section number when you call it:

Sub NewSection(j as integer)

With ActiveDocument
.Sections(j).Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Sections(j).Footers(wdHeaderFooterPrimary).LinkToPrevious = False

..Sections(j).Footers(wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = True

..Sections(j).Footers(wdHeaderFooterPrimary).PageNumbers.StartingNumber = 1
.Sections(j).Headers(wdHeaderFooterFirstPage).LinkToPrevious = False
.Sections(j).Footers(wdHeaderFooterFirstPage).LinkToPrevious = False
End with


Greetings from California - zkid.
 
J

Jean-Guy Marcil

Debra Ann was telling us:
Debra Ann nous racontait que :
This worked awesome and solved two of my problems at the same time.
I can't thank you enough.

Thank you, thank you, thank you.

See, one "Thank you" would have been enough for me!

Glad I could help!

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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