Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Field codes do not update automatically when document is opened

    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

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    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
    [MS MVP - Word]

  3. The Following User Says Thank You to macropod For This Useful Post:

    bjoeng (2013-02-02)

  4. #3
    New Lounger
    Join Date
    Feb 2001
    Location
    Tulsa, Oklahoma, USA
    Posts
    10
    Thanks
    8
    Thanked 1 Time in 1 Post
    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.
    Cyndie Browning
    Tulsa, Oklahoma USA

  5. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by CyndieBrowning View Post
    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
    [MS MVP - Word]

  6. #5
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts
    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

  7. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    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
    [MS MVP - Word]

  8. The Following User Says Thank You to macropod For This Useful Post:

    bjoeng (2013-03-06)

  9. #7
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks macropod,

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

    Thanks
    Bjoeng

  10. #8
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Custom document property

    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
    Attached Files Attached Files
    Last edited by bjoeng; 2013-03-06 at 18:07. Reason: adding document

  11. #9
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    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
    [MS MVP - Word]

  12. The Following User Says Thank You to macropod For This Useful Post:

    bjoeng (2013-03-07)

  13. #10
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks macropod!

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

    Thanks a lot!

    \bjoeng

Posting Permissions

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