Share via

update fields automatically without printing

Anonymous
2020-03-07T13:57:07+00:00

Hi.  I am a Microsoft partner.

Is there a means to update all fields automatically without printing?  

Two issues:

  1. I want to update some fields when they change like "Last saved", "Number of Pages"
  2. It seems there is an underlying requirement to print a document a lot. It made sense throughout the late 20th century perhaps to always print your documents.  Everybody printed a document to read it.  Now with cheaper, easier to read display technology, mobile phones, tablets, transferring documents through e-mail, and other social media, the "soft" copy is becoming the only copy.  There is no inherent need to print anymore.  I do not print unless a form requires it.

Enhancement Request:

  1. If the value of certain fields changes in the document that don't change constantly, all usages of the same fields should be updated automatically, this is considered follow-through.
    1. If the Author, Title, Version, Project and any other "Custom" field that is updated manually in the document properties, it should be updated in the document automatically where used as part of follow-through, it should not have to be updated twice for one result.
    2. Document Saved date/time should be updated when the document is saved automatically
  2. Per the original setup with a trigger to "Update Fields", I understand there may be conditions where field updates are not desired or could take a lot of time,  these are not included in the enhancement request.

The current scenario,

  1. Pre-Conditions
    1. This is on Word:: Mac.  I have not tried it personally on Word:: Windows or Word:: Linux however it is in online help for "Word::Windows" so it appears the same condition is implementation-independent.  I've changed the steps in the scenario to not be version-specific.
    2. I have the "number of pages" and "last saved date" fields in a table on the first/title page of my document.
    3. I also have the same information on the footer of each page.  I don't need both but the template came with it and there is surprisingly different behavior between the two
    4. In the Print Options settings, I select "Update Fields" and "Update Links"
  2. Actions:
    1. I add a page
    2. I save the document.
  3. Observations:
    1. I still have the same number of pages on the title page.
    2. The last saved date is the same on the title page.
    3. The "number of pages" is updated in the footer at the bottom of each page.
    4. The last saved date is the same on each page
  4. Actions:
    1. I choose to print the document
    2. I am prompted to "Update The Table of Contents", I select "Update Entire Table"
    3. The print dialog comes up, I select "Cancel"
  5. Observations:
    1. All my fields are correctly updated

Proposed Scenario

  1. Same Pre-Conditions.  Item 4 becomes irrelevant because people rarely print anymore.
  2. Previous Item 2 Actions are the same
  3. Observations
    1. All references to the "Number of pages" whether part of the footer or not, are updated.
    2. The last saved date field is updated automatically when the document is saved wherever it is used.
  4. Any other actions or observations are no longer required.
Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

John Korchok 232.4K Reputation points Volunteer Moderator
2020-03-07T21:22:27+00:00

This code will update the entire TOC:

Sub UpdateAll()

    Dim oStory As Range

    Dim oTOC As TableOfContents

    For Each oStory In ActiveDocument.StoryRanges

        oStory.Fields.Update

        If oStory.StoryType <> wdMainTextStory Then

            While Not (oStory.NextStoryRange Is Nothing)

                Set oStory = oStory.NextStoryRange

                oStory.Fields.Update

            Wend

        End If

    Next oStory

    For Each oTOC In ActiveDocument.TablesOfContents

        oTOC.Update

    Next oTOC

    Set oStory = Nothing

End Sub

In addition to TableOfContents, you can use TableOfAuthorities and TableOfFigures, just add similar loops for them.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

6 additional answers

Sort by: Most helpful
  1. John Korchok 232.4K Reputation points Volunteer Moderator
    2020-03-07T16:16:32+00:00

    Here's how to trigger a macro from a built-in command:

    1. In Word, choose Tools>Macros>Macros.
    2. Change the Macros in dropdown to Word commands.
    3. Select the command you want to act as a trigger, like FileSave.
    4. With the dialog still open, change Macros in to Normal.dotm (global template).
    5. Click on the plus sign. The VBE opens with a stub macro that is called FileSave and has only the ActiveDocument.Save command.
    6. Copy and paste the VBA code I posted into the macro before the ActiveDocument.Save line.
    7. Choose File>Save Normal, then close the VBE.
    8. Test that saving updates the fields.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2020-03-07T15:58:14+00:00

    OK.  I'm very familiar with VBA macros for Excel, I don't have as much experience with VBA macros for Word though I understand word for word what is being proposed.  If you can provide instructions for initiating the macro, I can take it from there.

    I want the "Last Saved" field to be updated everywhere when the document is saved and the "Number of pages" field to be updated automatically when there is +/- another page for now.

    When updating "Table of Contents/Figures/Tables, I always want to "Update Entire Table" because it is never just the page number.  It is annoying to be prompted 3 times for every update.  Since the document is relatively small (20 pages), I would update every field if there weren't so many repetitive "What would you like to Update" prompts.

    Was this answer helpful?

    0 comments No comments
  3. John Korchok 232.4K Reputation points Volunteer Moderator
    2020-03-07T15:31:35+00:00

    For fields that are in the body of the document, please choose Command + A to select all, then F9 to update the fields.

    Word fields require a triggering event to update them. Here is a macro from Graham Mayor that updates all fields, including headers and footers. You can call this from a Save command to run this automatically, please post if you need help setting that up:

    Sub UpdateAll()

        Dim oStory As Range

        For Each oStory In ActiveDocument.StoryRanges

            oStory.Fields.Update

            If oStory.StoryType <> wdMainTextStory Then

                While Not (oStory.NextStoryRange Is Nothing)

                    Set oStory = oStory.NextStoryRange

                    oStory.Fields.Update

                Wend

            End If

        Next oStory

        Set oStory = Nothing

    End Sub

    You can post your feature requests at the Word for Mac User Voice forum. That's the place Microsoft checks for user ideas.

    Was this answer helpful?

    0 comments No comments
  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more