Advertisement
Alexislls

Untitled

Jul 25th, 2019
3,200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub UpdateAllFields()
  2. Dim rngStory As Word.Range
  3. Dim lngValidate As Long
  4. Dim oShp As Shape
  5. Dim oToc As TableOfContents, oTOA As TableOfAuthorities, oTOF As TableOfFigures
  6. lngValidate = ActiveDocument.Sections(1).Headers(1).Range.StoryType
  7.   For Each rngStory In ActiveDocument.StoryRanges
  8.     'Iterar a través de todas las historias enlazadas
  9.    Do
  10.       On Error Resume Next
  11.       rngStory.Fields.Update
  12.       Select Case rngStory.StoryType
  13.         Case 6, 7, 8, 9, 10, 11
  14.           If rngStory.ShapeRange.Count < 0 Then
  15.             For Each oShp In rngStory.ShapeRange
  16.               If oShp.TextFrame.HasText Then
  17.                  oShp.TextFrame.TextRange.Fields.Update
  18.               End If
  19.             Next
  20.           End If
  21.         Case Else
  22.           'Do Nothing
  23.      End Select
  24.       On Error GoTo 0
  25.       'Obtener la siguiente historia enlazada (si la hay)
  26.      Set rngStory = rngStory.NextStoryRange
  27.     Loop Until rngStory Is Nothing
  28.     'Casos Especiales
  29.    For Each oToc In ActiveDocument.TablesOfContents
  30.       oToc.Update
  31.     Next oToc
  32.     For Each oTOA In ActiveDocument.TablesOfAuthorities
  33.       oTOA.Update
  34.     Next
  35.     For Each oTOF In ActiveDocument.TablesOfFigures
  36.       oTOF.Update
  37.     Next
  38.   Next
  39. lbl_Exit:
  40.   Exit Sub
  41. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement