Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub UpdateAllFields()
- Dim rngStory As Word.Range
- Dim lngValidate As Long
- Dim oShp As Shape
- Dim oToc As TableOfContents, oTOA As TableOfAuthorities, oTOF As TableOfFigures
- lngValidate = ActiveDocument.Sections(1).Headers(1).Range.StoryType
- For Each rngStory In ActiveDocument.StoryRanges
- 'Iterar a través de todas las historias enlazadas
- Do
- On Error Resume Next
- rngStory.Fields.Update
- Select Case rngStory.StoryType
- Case 6, 7, 8, 9, 10, 11
- If rngStory.ShapeRange.Count < 0 Then
- For Each oShp In rngStory.ShapeRange
- If oShp.TextFrame.HasText Then
- oShp.TextFrame.TextRange.Fields.Update
- End If
- Next
- End If
- Case Else
- 'Do Nothing
- End Select
- On Error GoTo 0
- 'Obtener la siguiente historia enlazada (si la hay)
- Set rngStory = rngStory.NextStoryRange
- Loop Until rngStory Is Nothing
- 'Casos Especiales
- For Each oToc In ActiveDocument.TablesOfContents
- oToc.Update
- Next oToc
- For Each oTOA In ActiveDocument.TablesOfAuthorities
- oTOA.Update
- Next
- For Each oTOF In ActiveDocument.TablesOfFigures
- oTOF.Update
- Next
- Next
- lbl_Exit:
- Exit Sub
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement