I need a toolbar button to add the word Proprietary to all the headers in a
document. I will not know how many headers the user has when doing this,
whether they are same as previous or not, etc.

How could I create a loop that would keep going to the next header and
adding it until there are no more headers left?

Thanks
--
Debra Ann

Re: Change All Headers by Jezebel

Jezebel
Fri Nov 18 14:57:13 CST 2005

Dim pRange as Word.Range
Dim pIndex as long

For pIndex = 1 to 3

on error resume next Ignore error if document doesn't have this
type of header
set pRange = ActiveDocument.StoryRanges(Choose(pIndex,
wdFirstPageHeaderStory, wdPrimaryHeaderStory, wdEvenPagesHeaderStory))
on error goto 0

Do until pRange is nothing
... [ do whatever]
set pRange = pRange.NextStoryRange 'Get next header of this
type, if any
Loop

Next





"Debra Ann" <DebraAnn@discussions.microsoft.com> wrote in message
news:856ED187-D235-4C68-B8DA-8CC73886420A@microsoft.com...
>I need a toolbar button to add the word Proprietary to all the headers in a
> document. I will not know how many headers the user has when doing this,
> whether they are same as previous or not, etc.
>
> How could I create a loop that would keep going to the next header and
> adding it until there are no more headers left?
>
> Thanks
> --
> Debra Ann