Updating fields: footer doesn't update right 
Author Message
 Updating fields: footer doesn't update right

I use Microsoft-code (from the KB, see below) to update alle fields,
including header and footer in my document. The template consists
default of five pages. But when I execute the code, the footer isn't
updated properly. Each time I do a refresh or I open the file, the
NumPages property in the footer jumps back to 1. I have to manually
refresh in order to get the property set properly again. Anybody got
any idea how to resolve this?

I use the following (Microsoft) code for refresh:
Dim aStory As Range
Dim aField As Field
For Each aStory In ActiveDocument.StoryRanges
    For Each aField In aStory.Fields
        aField.Update
    Next aField
Next aStory



Sun, 12 Sep 2004 16:49:22 GMT  
 Updating fields: footer doesn't update right
Hi Rosie,

What version of Word is this? NumPages updating incorrectly has been
a problem in a number of versions of Word, and the problem is usually
printer-specific.

Quote:
> But when I execute the code, the footer isn't
> updated properly. Each time I do a refresh or I open the file, the
> NumPages property in the footer jumps back to 1. I have to manually
> refresh in order to get the property set properly again.

If you use a macro that specifically updates the fields in a
header/footer, one-by-one, does the NumPages field update correctly
when you step through the macro using F8? If yes, then I'd Lock the
fields. Something like this (untested):

    Dim rng as Range, fld as Field
    Set rng = _
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range
    For each fld in rng.Fields
        If fld.Type = wdFieldNumPages Then
            fld.Unlock
            fld.Update
            fld.Lock
        Else
            fld.Update
        End If
    Next fld

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 :-)



Wed, 15 Sep 2004 18:32:53 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB6,Access97,ADO - Update query doesn't update all records

2. List Box Doesn't Get Updated After Create/Update/Delete Event

3. Recordset.Update doesn't update on runtime only when debugging the code

4. HELP...Informix Database ..rs.UPDATE doesn't work with Char-Fields

5. HELP...Informix Database ..rs.UPDATE doesn't work with Char-Fields

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

7. Updating fields in Headers/Footers

8. Updating fields in the footer story (both even and odd)

9. Updating ref field in footer vba code

10. Updating fields in a document footer

11. Fields in Header -- Footer not updating

12. Update fields in headers and footers

 

 
Powered by phpBB® Forum Software