remove LOTS of "Same as Previous"

L

Lori Luli

We have a large number of big documents(500+ pgs) that
frequently switch back and forth between portrait and
landscape. A section break (next page) is used between
each orientation change, so there are LOTS of sections in
each document.

We now need to go into these documents and re-format the
headers an footers, with portrait header/footers being
different from those of landscape.

The sections all have "Same as Previous" turned on for
both the header and the footer. I've been trying to
generate a macro that will go into the header of a
section, turn off "Same as Previous", switch to the footer
of that same section and turn off "Same as Previous", then
move to the next section.

The following code is my latest (failed) attempt. It
turns off "Same as Previous" for the current header, the
next footer, and does not advance to the next section.

Sub ClearSameAsPrev()
' Make sure the document is in Print Layout mode
Set myView = ActiveWindow.ActivePane.View
myView.Type = wdPrintView
' Turn off "Same as Previous" for header
myView.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = False
' Turn off "Same as Previous" for footer
myView.SeekView = wdSeekCurrentPageFooter
Selection.HeaderFooter.LinkToPrevious = False
' Go to next Section
myView.NextHeaderFooter
End Sub

Any suggestions??
 
D

Doug Robbins - Word MVP

Hi Lori,

This should do it:

For i = 2 To ActiveDocument.Sections.Count
With ActiveDocument.Sections(i)
.Headers(wdHeaderFooterFirstPage).LinkToPrevious = False
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Footers(wdHeaderFooterFirstPage).LinkToPrevious = False
.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
End With
Next i

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
W

Word Heretic

G'day "Lori Luli" <[email protected]>,

wrong methdology - don't view, rather deal direct with the objects

I would check out ActiveDocument.StoryRanges right now for the most
pleasant surprise :) Then, there's an extra bonus. Due to the crappy
way MS have made everything a calculated object, there's a second way
into the mess you seek

ActiveDocument.Content.Sections(k).Headers
ActiveDocument.Content.Sections(k).Footers

Pick the object structure most suitable for your needs and the macro
writes itself :)



Lori Luli said:
We have a large number of big documents(500+ pgs) that
frequently switch back and forth between portrait and
landscape. A section break (next page) is used between
each orientation change, so there are LOTS of sections in
each document.

We now need to go into these documents and re-format the
headers an footers, with portrait header/footers being
different from those of landscape.

The sections all have "Same as Previous" turned on for
both the header and the footer. I've been trying to
generate a macro that will go into the header of a
section, turn off "Same as Previous", switch to the footer
of that same section and turn off "Same as Previous", then
move to the next section.

The following code is my latest (failed) attempt. It
turns off "Same as Previous" for the current header, the
next footer, and does not advance to the next section.

Sub ClearSameAsPrev()
' Make sure the document is in Print Layout mode
Set myView = ActiveWindow.ActivePane.View
myView.Type = wdPrintView
' Turn off "Same as Previous" for header
myView.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = False
' Turn off "Same as Previous" for footer
myView.SeekView = wdSeekCurrentPageFooter
Selection.HeaderFooter.LinkToPrevious = False
' Go to next Section
myView.NextHeaderFooter
End Sub

Any suggestions??

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email (e-mail address removed)
Products http://www.geocities.com/word_heretic/products.html

Replies offlist may require payment.
 

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