![]() |
|
#1
|
|||
|
|||
|
I used the website below to create a shortcut button and update all fields in my document but it won't update the index! how can I include index in the macro code? Installing Macros |
|
#2
|
||||
|
||||
|
The Fields.Update method doesn't update everything; page #s yes, but TOC entries, etc., no. A simpler, yet more comprehensive, macro is:
Code:
Sub UpdateFields() Application.ScreenUpdating = False With ActiveDocument .Fields.Update .PrintPreview .ClosePrintPreview End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
I tried your code. it works for the fields but not for my table of content.
|
|
#4
|
||||
|
||||
|
OK, try:
Code:
Sub RefreshFields()
Application.ScreenUpdating = False
Dim TOC As TableOfContents ' Table of Contents Object
Dim TOA As TableOfAuthorities ' Table of Authorities Object
Dim TOF As TableOfFigures ' Table of Figures Object
Dim Rng As Range ' Range Object
Dim Idx As Index ' Index Object
With ActiveDocument
' Loop through Story Ranges and update.
' Note that this may trigger interactive fields (eg ASK and FILLIN).
For Each Rng In .StoryRanges
Do
Rng.Fields.Update
Set Rng = Rng.NextStoryRange
Loop Until Rng Is Nothing
Next
' Loop through Tables Of Contents and update
For Each TOC In .TablesOfContents
TOC.Update
Next
' Loop through Tables Of Authorities and update
For Each TOA In .TablesOfAuthorities
TOA.Update
Next
' Loop through Tables Of Figures and update
For Each TOF In .TablesOfFigures
TOF.Update
Next
' Loop through Indices and update
For Each Idx In .Indexes
Idx.Update
Next
.PrintPreview
.ClosePrintPreview
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
It works perfectly! Thanks
|
|
| Tags |
| index, table of content, update field |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Update Styleref Fields | datech-hh | Word VBA | 18 | 11-04-2017 01:35 PM |
Keep Loosing Index Update Capability
|
Phil H | Word | 1 | 11-18-2014 04:06 PM |
| how to update calculated fields | sectionbreak | Mail Merge | 4 | 06-04-2014 12:12 AM |
| VBA to update certain (but not all) fields | sparkyrose | Word VBA | 0 | 05-20-2010 12:50 PM |
| Can no longer update fields! | slindsay | Word | 0 | 09-03-2009 05:10 PM |