• Field codes do not update automatically when document is opened

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Field codes do not update automatically when document is opened

    Author
    Topic
    #487228

    I have a file with header and footer containing Field codes Date last saved and Version number ({DOCPROPERTY ‘’RevisionNumber’’ * MERGEFORMAT }.
    The content of the field codes will not change when I save, close and opens the document again. I have to open the header, mark the field codes, rightckick and click Update Field.

    How can I get Word to update these field codes automatically when I open the document?
    I need to get these fields updated when I open the document and preferably also when the document is open(active) in Word. I understand from Word’s Help that field codes should be updated automatically.

    If I have to use macros, the document must not be deactivated for macros when another persion opens the document.

    I use Office 2010 (Word 2010) under Windows 7.

    Thanks a lot in advance

    Bjoeng

    Viewing 5 reply threads
    Author
    Replies
    • #1372045

      Hi Bjoeng,

      By design, most Word fields do not update automatically, even when they’re in a header or footer. Simply switching to/from print preview should be enough to update the fields, though.

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1377605

      macropod wrote: “Simply switching to/from print preview should be enough to update the fields, though.”
      OR you can open the document, press CTRL+A (to Select All) and then hold down the CTRL and Shift keys and press F9. Immediately, all fields in the document are updated.

      • #1377661

        OR you can open the document, press CTRL+A (to Select All) and then hold down the CTRL and Shift keys and press F9. Immediately, all fields in the document are updated.

        THAT IS BOTH WRONG AND DANGEROUS
        What you’re advising would result in all fields in the body of the document not being updated and, instead, being converted to plain text so they could never be updated again!!!!!!!

        The alternate approach that uses Ctrl-A, F9 (not Ctrl-A, then Ctrl-Shift-F9) only updates fields in the body of the document. It does not update fields in textboxes, headers, footers, footnotes, endnotes, etc.

        Cheers,
        Paul Edstein
        [Fmr MS MVP - Word]

    • #1377834

      Thanks macroprod.

      I will then use a macro to update the Fields.
      The only problem with having a macro in a document I send to a friend is that my friend will get the choice of accepting or not. Likely he will not accept, thinking it is dangerous. So how to overcome such a problem?

      Thanks
      bjoeng

    • #1377861

      Hi bjoeng,

      You can’t do anything from your end to affect whether someone you send a document to will generate a macro-security warning.

      However, I can suggest a workaround. First, add a custom document property, of the Yes/No type and named ‘Rev’ to your document. Then change the ‘Revision’ field code you’re now using to:
      {={DOCPROPERTY “RevisionNumber”}+{IF{DOCPROPERTY “Rev”}= “Y” 1 0 }}
      Now, before saving the document, set the Rev property to ‘Yes’, then update the field. Re-set the Rev property to ‘No’, then save the document.

      The effect of this is circumlocution is to increment the displayed Revision number to the same as it will display next time the document is opened, whether or not anything occurs to update the field code display.

      The above process can be automated with the following macro, which you can add to the document’s template, rather than the document itself. That way, your document needn’t contain any macros and its recipients also won’t need to concern themselves with them.

      Code:
      Sub SetRev()
      Application.ScreenUpdating = False
      With ActiveDocument
        .CustomDocumentProperties("Rev").Value = True
        .StoryRanges(wdPrimaryHeaderStory).Fields.Update
        .CustomDocumentProperties("Rev").Value = False
        .Save
      End With
      Application.ScreenUpdating = True
      End Sub

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

      • #1378507

        Hi,

        I have tried your suggestions but I cannot get it working.
        I get error message:
        !Syntaksfeil, {

        The original code is: { DOCPROPERTY RevisionNumber * MERGEFORMAT }

        The code giving error is: {={DOCPROPERTY RevisionNumber }+{IF{ DOCPROPERTY Rev }= Y 1 0 } * MERGEFORMAT }

        I have also trided with {={DOCPROPERTY “RevisionNumber” }+{IF{ DOCPROPERTY “Rev” }= “Y” 1 0 }}
        but I get the same Syntax error. (also using * MERGEFORMAT}

        So what can be wrong?

        I have attached a document with the code.

        Thanks
        bjoeng

        • #1378542

          The problem is that the nested ‘fields’ in your document are just plain text. All of field brace pairs (ie ‘{ }’) for the field example I posted are created in the the document via Ctrl-F9 (Cmd-F9 on a Mac) – you can’t simply type them or copy & paste them from the board. Also, you don’t need/want the ‘* MERGEFORMAT’ switches.

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

    • #1377921

      Thanks macropod,

      I will try this and see how it works out in some days.

      Thanks
      Bjoeng

    • #1378556

      Thanks macropod!

      I was not aware of that. I will change the way I generate the code.

      Thanks a lot!

      bjoeng

    Viewing 5 reply threads
    Reply To: Field codes do not update automatically when document is opened

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

    Your information: