Updating fields in Headers/Footers 
Author Message
 Updating fields in Headers/Footers

I have REF fields in header and footers.  I want a macro
to update all the header/footers in my document.  I can
create a macro with the macro recorder that works when I
know how many sections there are in my document.  The
problem is if a user adds a new section or more and wants
to update all the REF fields.  I need something that
works out how many sections there are and updates
accordingly.

I am a real beginner with VBA and have not worked out
what I need.

Any help gratefully received



Fri, 17 Dec 2004 01:30:36 GMT  
 Updating fields in Headers/Footers
Hi Sandy,

You should be able to use For Each... Next to loop through
all the section, regardless of how many there are. An
alternative method is to get the Sections.Count and use a
"normal" For... Next. You'll find both in the general VBA
Help if you want to read up on them.

I suggest you take the code you have now to update the
fields and use it like this

Dim sec as Word.Section

For Each sec in ActiveDocument.Sections
    'Put your code that updates the fields here
Next sec

Quote:
> I have REF fields in header and footers.  I want a macro
> to update all the header/footers in my document.  I can
> create a macro with the macro recorder that works when I
> know how many sections there are in my document.  The
> problem is if a user adds a new section or more and wants
> to update all the REF fields.  I need something that
> works out how many sections there are and updates
> accordingly.

> I am a real beginner with VBA and have not worked out
> what I need.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)



Fri, 17 Dec 2004 17:23:22 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to update fields in a footer (header) ?

2. Fields in Header -- Footer not updating

3. Update fields in headers and footers

4. Updating fields: footer doesn't update right

5. Fields in headers/footers

6. Unlinking Fields in Headers/Footers

7. Fields in Headers/Footers

8. Page field, header/footer

9. Getting Merge Field from a Word Document Header and Footer

10. Accessing fields in header/footer

11. Accessing fields in header/footer

12. Form fields in Headers and Footers or Auto fill

 

 
Powered by phpBB® Forum Software