Results 1 to 6 of 6
  1. #1
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts

    updating crossreference fileds (Word 2003)

    Hello all,

    I have a form with a lot of fields in it.
    The form starts with 6 fields that will also show in the headers of following pages by using crossreferences
    When changing the first 6 fields, the crossreferences on the following pages are not automaticly updated (those will update when I change the view to Print preview)
    Is it possible to use some VBA code that will update the crossreferece fields in the headers each time the user leaves one of the first 6 fields?

    Thanks in advance for your reaction.
    Greetings,

    Patrick Schouten
    (The Netherlands)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: updating crossreference fileds (Word 2003)

    You can create a macro that either updates the cross references in the header/footer, or updates all fields in the document, and specify this macro to be run On Exit in the properties of the form field. The macro could look like this:


    Sub UpdateHeader()
    ActiveDocument.Sections(1).Headers(wdHeaderFooterP rimary).Range.Fields.Update
    End Sub

    or

    Sub UpdateAll()
    Dim rng As Range
    For Each rng In ActiveDocument.StoryRanges
    rng.Fields.Update
    Next rng
    End Sub

    The latter will cause a noticeable delay!

  3. #3
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: updating crossreference fileds (Word 2003)

    Hello Hans,

    I have tried both solutions, but they are not working
    I even tried to unprotect the document before the update, but that is also not working.
    The referencefields in the header are not updated, only when I swith to Print Preview
    Greetings,

    Patrick Schouten
    (The Netherlands)

  4. #4
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: updating crossreference fileds (Word 2003)

    Hans,

    I solved it.
    The secions(1) is the problem... because the document has more sections

    Thanks,
    Patrick
    Greetings,

    Patrick Schouten
    (The Netherlands)

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: updating crossreference fileds (Word 2003)

    If necessary, you can loop through the sections of the document, and also through the types of header (primaryheader, first page header and even pages header).

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: updating crossreference fileds (Word 2003)

    Hi Patrick,

    This may do the trick:
    Sub UpdateHeader()
    Application.ScreenUpdating = False
    ActiveDocument.PrintPreview
    ActiveDocument.ClosePrintPreview
    Application.ScreenUpdating = True
    End Sub
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •