L
Laura
Hello and thanks in advanced:
I’m trying to build a TOC manually
I have to take all the phrases that are selected in the document, an put it
in a table of contents
The pseudo-code should be something like this:
Do
Look for underlined text
Place a mark Entry (at the beginning of the line)
loop Until end of document
Write the index at the beginning of the document
Well, my problem is that i don't know what it's wrong in my code, or waht i
have to do. the program, at the end of the document, begins another at the
beginning
thanks
Sub Macro()
'
'
Dim indice As String
Windows("combina.doc").Activate
Selection.WholeStory
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Do
Selection.Find.ClearFormatting
With Selection.Find
.Font.Underline = True
.Text = ""
.Replacement.Text = "^p^p"
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
indice = Selection.Text
ActiveWindow.ActivePane.View.ShowAll = True
Selection.HomeKey Unit:=wdLine ‘ its necessary because if you
don’t put the markEntry at the beginning of the line, it becomes an infinite
secuence
ActiveDocument.Indexes.MarkEntry Range:=Selection.Range,
Entry:=indice
Loop Until ?????
‘ write the index at the beginning of the document
Selection.WholeStory
Selection.MoveLeft Unit:=wdCharacter, Count:=1
With ActiveDocument
.Indexes.Add Range:=Selection.Range, HeadingSeparator:= _
wdHeadingSeparatorNone, Type:=wdIndexIndent,
RightAlignPageNumbers:= _
True, NumberOfColumns:=1, IndexLanguage:=wdSpanishModernSort
.Indexes(1).TabLeader = wdTabLeaderDots
End With
End Sub
I’m trying to build a TOC manually
I have to take all the phrases that are selected in the document, an put it
in a table of contents
The pseudo-code should be something like this:
Do
Look for underlined text
Place a mark Entry (at the beginning of the line)
loop Until end of document
Write the index at the beginning of the document
Well, my problem is that i don't know what it's wrong in my code, or waht i
have to do. the program, at the end of the document, begins another at the
beginning
thanks
Sub Macro()
'
'
Dim indice As String
Windows("combina.doc").Activate
Selection.WholeStory
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Do
Selection.Find.ClearFormatting
With Selection.Find
.Font.Underline = True
.Text = ""
.Replacement.Text = "^p^p"
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
indice = Selection.Text
ActiveWindow.ActivePane.View.ShowAll = True
Selection.HomeKey Unit:=wdLine ‘ its necessary because if you
don’t put the markEntry at the beginning of the line, it becomes an infinite
secuence
ActiveDocument.Indexes.MarkEntry Range:=Selection.Range,
Entry:=indice
Loop Until ?????
‘ write the index at the beginning of the document
Selection.WholeStory
Selection.MoveLeft Unit:=wdCharacter, Count:=1
With ActiveDocument
.Indexes.Add Range:=Selection.Range, HeadingSeparator:= _
wdHeadingSeparatorNone, Type:=wdIndexIndent,
RightAlignPageNumbers:= _
True, NumberOfColumns:=1, IndexLanguage:=wdSpanishModernSort
.Indexes(1).TabLeader = wdTabLeaderDots
End With
End Sub