1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
Sub IndexTables()
Dim strTable As String
Dim strPrevTable As String
strTable = ""
strPrevTable = ""
Selection.HomeKey Unit:=wdStory
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
tot = Selection.End
Selection.HomeKey Unit:=wdStory
posit = 1
oldposit = 0
Do While posit >= oldposit
oldposit = posit
Selection.Find.ClearFormatting
With Selection.Find
.Text = " Table "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
posit = Selection.End
Debug.Print oldposit; posit; tot
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
strTable = Selection.Text
If posit >= oldposit And strTable <> strPrevTable Then
ActiveWindow.ActivePane.View.ShowAll = True
ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, Entry:= _
strTable, EntryAutoText:= _
strTable, CrossReference:="", _
CrossReferenceAutoText:="", BookmarkName:="", Bold:=False, Italic:=False
End If
Debug.Print strPrevTable; strTable
strPrevTable = strTable
Debug.Print posit;
Loop
End Sub |
Partager