Change All Headers

D

Debra Ann

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
 
J

Jezebel

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
 

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