Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Turning Off Same as Previous

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jerem - 02 Sep 2007 15:56 GMT
Just a heads up,  VBA knowledge:  low novice

Aside from manually going into each Header or Footer and deselecting Same as
Previous (the bane of Word's existence) does anyone out there have a macro to
do it in one sweep (taking out every designation in all Headers and Footers).
Had one in my previous job, but did not think to take it with me.

Thanks in advance.
Greg Maxey - 02 Sep 2007 18:12 GMT
Sub ScratchMacro()
Dim oSect As Section
Dim oFooter As HeaderFooter
Dim oHeader As HeaderFooter
Dim i As Long
For Each oSect In ActiveDocument.Range.Sections
 For i = 1 To 3
     Set oFooter = oSect.Footers(Choose(i, wdHeaderFooterFirstPage, _
wdHeaderFooterPrimary, wdHeaderFooterEvenPages))
           Set oHeader = oSect.Headers(Choose(i, 1, _
wdHeaderFooterPrimary, wdHeaderFooterEvenPages))
     Set oHeader = oSect.Headers(Choose(i, wdHeaderFooterFirstPage, _
wdHeaderFooterPrimary, wdHeaderFooterEvenPages))
     oFooter.LinkToPrevious = False
     oHeader.LinkToPrevious = False
 Next
Next oSect
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Just a heads up,  VBA knowledge:  low novice
>
[quoted text clipped - 5 lines]
>
> Thanks in advance.
Greg Maxey - 02 Sep 2007 19:58 GMT
I suppose it doesn't have to be as lengthy as my previous post:

Sub ScratchMacro()
Dim oSect As Section
Dim i As Long
For Each oSect In ActiveDocument.Range.Sections
 For i = 1 To 3
     oSect.Footers(i).LinkToPrevious = False
     oSect.Headers(i).LinkToPrevious = False
 Next
Next oSect
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Just a heads up,  VBA knowledge:  low novice
>
[quoted text clipped - 5 lines]
>
> Thanks in advance.
Russ - 04 Sep 2007 10:37 GMT
Greg,
I think this macro changes literally the first three headers and footers of
each section? What if there is less than three or more than three headers
and footers?

> I suppose it doesn't have to be as lengthy as my previous post:
>
[quoted text clipped - 8 lines]
> Next oSect
> End Sub

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Greg Maxey - 04 Sep 2007 12:46 GMT
Russ,

That code is the same as doing this:

Sub ScratchMacroII()
Dim oSect As Section
For Each oSect In ActiveDocument.Range.Sections
 oSect.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
 oSect.Footers(wdHeaderFooterEvenPages).LinkToPrevious = False
 oSect.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
 oSect.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
 oSect.Headers(wdHeaderFooterEvenPages).LinkToPrevious = False
 oSect.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
Next oSect
End Sub

Look up one of the elements in "(  )" using the object browser and you will
see the contstant values of 1 2 or 3.

AFAIK, each there are three storytypes available to each section (no more
and no less) regardless if they are physically used in the document.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Greg,
> I think this macro changes literally the first three headers and footers
[quoted text clipped - 14 lines]
>> Next oSect
>> End Sub
Russ - 20 Sep 2007 19:12 GMT
Greg,
So headers and footers collections are indexed differently.
Does this mean that if I wanted to change the .linktoprevious on the the
tenth page of the section only (unusual, I know), I can't use for example
oSect.Footers(10).linktoprevious = false?
I'd have to use something like pseudocode:
oSect.Page(10).footers(1).linktoprevious = false?

Or what would be the best way to it?

> Russ,
>
[quoted text clipped - 17 lines]
> AFAIK, each there are three storytypes available to each section (no more
> and no less) regardless if they are physically used in the document.

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Greg Maxey - 21 Sep 2007 00:08 GMT
Russ,

The code I meant to post is:

Sub ScratchMacroII()
Dim oSect As Section
For Each oSect In ActiveDocument.Range.Sections
  oSect.Footers(wdHeaderFooterFirstPage).LinkToPrevious = False
  oSect.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
  oSect.Footers(wdHeaderFooterEvenPages).LinkToPrevious = False
  oSect.Headers(wdHeaderFooterFirstPage).LinkToPrevious = False
  oSect.Headers(wdHeaderFooterEvenPages).LinkToPrevious = False
  oSect.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
Next
End Sub

There are six story ranges that are associated with Headers and Footers.  A
First Page, Primary (Odd Pages), and Even Pages.  Every section can contain
all six.  AFAIK there is no way that you can isolate a single page (e.g.,
page 10) of a section to toggle the LinkToPrevious attribute.

If you wanted to remove link to previous say in section 4 footer Even pages
only then you could code like this:

ActiveDocument.Sections(4).Footers(wdHeaderFooterEvenPages).LinkToPrevious =
False

or substitute wdHeaderFooterEvenPages with its constant "3"

ActiveDocument.Sections(4).Footers(3).LinkToPrevious = False

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Greg,
> So headers and footers collections are indexed differently.
[quoted text clipped - 28 lines]
>> AFAIK, each there are three storytypes available to each section (no more
>> and no less) regardless if they are physically used in the document.
fumei - 21 Sep 2007 06:45 GMT
Actually, every Section does contain all six.  There is no "can".  They do.
Greg Maxey - 21 Sep 2007 10:24 GMT
Yes I know that.  I waffled about just stating that, but thought it might
make things confusing when many sections "appear" to contain only one type
of header/footer.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Actually, every Section does contain all six.  There is no "can".
> They do.
Russ - 21 Sep 2007 10:21 GMT
Greg and fumei,
OK, thanks for the info.

> Russ,
>
[quoted text clipped - 26 lines]
>
> ActiveDocument.Sections(4).Footers(3).LinkToPrevious = False

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

jerem - 05 Sep 2007 05:26 GMT
Tried it on a doc with 10 Sections breaks and it turned off Same as Previous
on all of them.  Thanks Greg, it works great.

> I suppose it doesn't have to be as lengthy as my previous post:
>
[quoted text clipped - 18 lines]
> >
> > Thanks in advance.
jerem - 05 Sep 2007 05:26 GMT
Turned off Same as Previous on a doc with 10 Section breaks so you're right -
the short version works fine.  Thanks.

> I suppose it doesn't have to be as lengthy as my previous post:
>
[quoted text clipped - 18 lines]
> >
> > Thanks in advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.