Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 10-20-2017, 02:10 PM
macropod's Avatar
macropod macropod is offline Update Styleref Fields Windows 7 64bit Update Styleref Fields Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The following macro should be fairly quick at updating your Index entries:
Code:
Sub IndexUpdater()
Application.ScreenUpdating = False
Dim i As Long, strStl As String, strRef As String
With ActiveDocument
  For i = 1 To .Fields.Count
    With .Fields(i)
      If .Type = wdFieldIndexEntry Then
        If .Code.Fields.Count = 1 Then
          With .Code.Fields(1)
            If .Type = wdFieldStyleRef Then
              strStl = .Code.Paragraphs(1).Style
              strRef = Split(Split(.Code.Text, "STYLEREF")(1), Chr(34))(1)
              If strRef <> strStl Then .Code.Text = Replace(.Code.Text, strRef, strStl)
            End If
          End With
        End If
      ElseIf .Type = wdFieldIndex Then
        .Update
      End If
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
As for your Tables of Contents, that may or may not need updating. The code for that, if you need it, is as simple as adding:
.TablesOfContents(1).Update
before the final 'End With'. Do note that a Tables of Contents inserted via References|Tables of Contents is far slower at updating than one created by inserting a TOC field. That's because the Tables of Contents inserted via References|Tables of Contents gets inserted in a kind of content control and it's that that imposes the performance hit.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Styleref Fields How do I update all fields from a new input Kozzzle Word 7 10-19-2017 06:12 PM
how to update calculated fields sectionbreak Mail Merge 4 06-04-2014 12:12 AM
Macro to update fields rhatx Word VBA 0 03-02-2011 12:14 PM
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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft