R
Roderick O'Regan
I have a document with Odd and Even pages headers and footers.
At this point I insert a new section and which I have to remove the
header and footer linking to the previous section.
I create a temporary bookmark, add a page break, unlink the primary
and even headers and footers, remove the bookmark and then the page
break.
Everything works as it should and there is no problem.
However, below is the code which does all the unlinking and I just
wanted to say the same thing but with a little more elegance and
finesse.
Could somebody therefore, please show me how these few lines might be
written in properly coded VBA?
======================
ActiveWindow.ActivePane.View.SeekView = wdSeekEvenPagesHeader
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Bookmarks("temp").Select
ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryHeader
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Bookmarks("temp").Select
ActiveWindow.ActivePane.View.SeekView = wdSeekEvenPagesFooter
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Bookmarks("temp").Select
ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryFooter
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
========================
You might wonder why all the backwards and forwards between the
headers, main document and back to the footers with the selection of
the temp bookmark in between?
Well, I found that Word "got lost"(i.e. didn't go to where I expected
it to go) if I told it to unlink the odd and even headers and then do
the same with the odd and even footers. It somehow got confused and
went and did things either in the previous section or the one
following the new section.
I created some explicit actions and that did the trick!!
Regards
Roderick
At this point I insert a new section and which I have to remove the
header and footer linking to the previous section.
I create a temporary bookmark, add a page break, unlink the primary
and even headers and footers, remove the bookmark and then the page
break.
Everything works as it should and there is no problem.
However, below is the code which does all the unlinking and I just
wanted to say the same thing but with a little more elegance and
finesse.
Could somebody therefore, please show me how these few lines might be
written in properly coded VBA?
======================
ActiveWindow.ActivePane.View.SeekView = wdSeekEvenPagesHeader
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Bookmarks("temp").Select
ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryHeader
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Bookmarks("temp").Select
ActiveWindow.ActivePane.View.SeekView = wdSeekEvenPagesFooter
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Bookmarks("temp").Select
ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryFooter
Selection.HeaderFooter.LinkToPrevious = False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
========================
You might wonder why all the backwards and forwards between the
headers, main document and back to the footers with the selection of
the temp bookmark in between?
Well, I found that Word "got lost"(i.e. didn't go to where I expected
it to go) if I told it to unlink the odd and even headers and then do
the same with the odd and even footers. It somehow got confused and
went and did things either in the previous section or the one
following the new section.
I created some explicit actions and that did the trick!!
Regards
Roderick