Mon 6 Dec 2004
Here is a simple and useful macro for MS Word which will update all of the linked cross-references in a document at once. A lifesaver!!
(This works for PC Word… haven't tested it for Mac. Let me know!)
Sub UpdateAll()
Dim oStory As Range
Dim oField As Field
For Each oStory In ActiveDocument.StoryRanges
For Each oField In oStory.Fields
oField.Update
Next oField
Next oStory
End Sub
works on mac…
Hey, when did you add that image validation thingy?
Judd, by the powers vested in me, I dub thee VBA programmer of SIMS.
I have one problem with that script… the document i am creating requires the the version number be listed in the main document body (coversheet). Problem being… I am using the RevNum, to get my Version number for the document and it is automatically updated in the footer, the code is cause the Revision number to jump up by two or more when the macro runs to update the fields. Any help would be greatly appreciated…
You're a God!! Thanks, I don't know anything about Macros, but i really need something like this!! Thanks again!
Use following macro to update all type of fields
in Word doc. The document will blink for millisec and will be refreshed.
Sub AutoOpen()
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
End Sub
thank you so much for posting this!
In 2011 still usefull! Thanks for your blog.
Does not work on Word 2007! I had used a similar version until i updated to Office 2007 last week.
Thanks Judd for this really helpful Word macro. I love such such easy but ingenious solutions.
BR, Sepp
I'm brand new to VBA (as in I just started playing with it today). I'm running word 2010, and I'm trying to link a document to a dropdown screen. This is the code I've written:
Sub UpdateAllFields()
'Dim oStory As Range
' UpdateAllFields Macro
'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
{IF{ Dropdown1 } = "Goal 1"{ INCLUDETEXT"C:\\users\\crouleau\\desktop\\Service Plan test\\Goal 1.docx"}"}{IF{ Dropdown1 } = "Goal 2"{ INCLUDETEXT"C:\\users\\crouleau\\desktop\\Service Plan test\\Goal 2.docx"}"}{IF{ Dropdown1 } = "Goal 3" INCLUDETEXT"C:\\users\\crouleau\\desktop\\Service Plan test\\Goal 3.docx"}"}{IF{ Dropdown1 } = "Goal 4"{ INCLUDETEXT"C:\\users\\crouleau\\desktop\\Service Plan test\\Goal 4.docx"}"}
Everytime I run it I get an error message that reads "Next without a For" with the last Next oStory highlighted.
Any suggestions?
You appear to have commented out the "For Each oStory" line along with "Dim oStory as Range".
When in the cross-reference "Text Form Field Options" there is a 'Run Macro on Exit' command that I am trying to utilize. Am I misunderstanding what this field is for?
Is there a way to have this macro activate when leaving a cross-reference field?
Thanks that worked perfectly, and it's so short.
Works a treat, nice 'n neat. Cheers.
Thank you so much Judd. Works perfectly in my home version of Word 2010 on PC. Updated all Tables, Figures, Equations including chapter numbers too.
You are a brilliant man who has just saved me hours.
I love this macro, works perfectly. I have very basic VB knowledge, can anyone tell me how to amend this to execute upon the file opening?