• updating crossreference fileds (Word 2003)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » updating crossreference fileds (Word 2003)

    Author
    Topic
    #449373

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #1101622

      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(wdHeaderFooterPrimary).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!

      • #1101623

        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

        • #1101624

          Hans,

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

          Thanks,
          Patrick

          • #1101625

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

          • #1101647

            Hi Patrick,

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

            Cheers,
            Paul Edstein
            [Fmr MS MVP - Word]

    Viewing 0 reply threads
    Reply To: updating crossreference fileds (Word 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: