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 53 54 55 56 57 58 59 60 61
|
Sub DVP_GenererMesTitresSansSautsDeLigne3()
'// Supprimer les anciens signets sur les titres
aI = ActiveDocument.Bookmarks.Count
While aI > 0
If InStr(ActiveDocument.Bookmarks(aI).Name, "SigTitreAutoA") = 1 Then
ActiveDocument.Bookmarks(aI).Delete
End If
aI = aI - 1
Wend
'// Ajouter les signets avant et après
aI = 1
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Titre 1")
With Selection.Find
.Text = "^l"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveLeft Unit:=wdCharacter, Count:=1
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="SigTitreAutoAvt_" + Format(aI, "###000")
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.MoveUp Unit:=wdParagraph, Count:=1
If aI > 1 Then
Selection.TypeParagraph
Selection.MoveUp Unit:=wdParagraph, Extend:=wdExtend
Selection.Style = ActiveDocument.Styles("Normal")
Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.Delete Unit:=wdCharacter, Count:=1
End If
ActiveDocument.Bookmarks("SigTitreAutoAvt_" + Format(aI, "###000")).Start = Selection.Start
Selection.GoTo What:=wdGoToBookmark, Name:="SigTitreAutoAvt_" + Format(aI, "###000")
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="SigTitreAutoAps_" + Format(aI, "###000")
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
aI = aI + 1
Selection.Find.Execute
Wend
End Sub |
Partager