I'm trying to update all the fields in a Word document using the "Fields.Update"-Method. This is the code I use:
Sub UpdateFields()
Dim varRange As Range
'Update fields in the first section of the main text
set varRange = ThisDocument.StoryRanges(wdMainTextStory)
varRange.Fields.Update
'Update fields in subsequent sections (of the main text)
While Not (varRange.NextStoryRange Is Nothing)
Set varRange = varRange.NextStoryRange
varRange.Fields.Update
Wend
End Sub
There are over 750 fields in the document (linking to cell content in an/one Excelfile) so the update takes a while so for the user it looks like the application "freezes". When I update "manually" (selecting via Crtl+A
and updating via F9
), I get a progress bar like this within the status bar at the bottom of the word application window:
However it does not appear using the "Fields.Update"-Methode. Is there a way to show this Bar using the Filds.Update-Method or any other Method?
I suppose I could make my own "progress"-bar via a userform. But this would require to update each field individually (e.g. through cycling through all fields indevidually rngCurrentRange.Fields(i).Update
) but I would rather avoid that. It makes the code more complex, slower and it's a pain in the ass to make sure Word keeps the userform updated in real time. But if there's no other solution I'll take that as well.
EDIT: I found a workaround, but it's not working 100%, please see my answer...
Please Note: I also posted two other questions within this context:
SendKeys
for the keyboard shortcut so that Word's progress bar displays. Another would be a message at the beginning informing the user that this takes a long time (possibly with the number of fields to be updated and a time estimate) so that the user knows to go get a cup of coffee. (Maybe with an image of that cup of coffee, steaming...). – Cindy Meister