Lorsqu'on numérote les paragraphes dans Word, l'effet n'est pas très satisfaisant. L’objectif est d’obtenir ceci :
1. Texte, texte, texte...
10. Texte, texte, texte...
100. Texte, texte, texte...
Cette vidéo vous montre comment on peut atteindre cet objectif en utilisant les styles de Word.
Pour faciliter cette opération, surtout si les paragraphes numérotés sont séparés par des titres de styles divers, voici une macro (lancez AjouteStyles) qui attribue un style différent en fonction du numéro de paragraphe. Si le paragraphe a un numéro qui va de 10 à 99, il aura le style "ListeNN", si le paragraphe a un numéro qui va de 100 à 999, il aura le style "ListeNNN" et si le paragraphe a un numéro qui va de 1000 à 9999, il aura le style "ListeNNNN".
La macro ici présentée donne un bon résultat si votre document est en Times New Roman 12.
Si ce n'est pas le cas, il suffira ensuite de modifier ces nouveaux styles (en jouant sur Retrait et Suspendu comme montré ici) pour obtenir une apparence satisfaisante.
Sub AjouteStyles()
'ListeNN
ActiveDocument.Styles.Add Name:="ListeNN", Type:=wdStyleTypeParagraph
ActiveDocument.Styles("ListeNN").AutomaticallyUpdate = False
With ActiveDocument.Styles("ListeNN").Font
.Name = "Times New Roman"
.Size = 12
.UnderlineColor = wdColorAutomatic
.Color = wdColorAutomatic
.Scaling = 100
.Kerning = 0
.NumberSpacing = wdNumberSpacingDefault
.NumberForm = wdNumberFormDefault
.StylisticSet = wdStylisticSetDefault
.ContextualAlternates = 0
End With
With ActiveDocument.Styles("ListeNN").ParagraphFormat
.LeftIndent = 38
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1.08)
.Alignment = wdAlignParagraphJustify
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = -24
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
.CollapsedByDefault = False
End With
ActiveDocument.Styles("ListeNN").NoSpaceBetweenParagraphsOfSameStyle = True
ActiveDocument.Styles("ListeNN").ParagraphFormat.TabStops.ClearAll
ActiveDocument.Styles("ListeNN").LanguageID = wdFrench
ActiveDocument.Styles("ListeNN").NoProofing = False
ActiveDocument.Styles("ListeNN").Frame.Delete
'ListeNNN
ActiveDocument.Styles.Add Name:="ListeNNN", Type:=wdStyleTypeParagraph
ActiveDocument.Styles("ListeNNN").AutomaticallyUpdate = False
With ActiveDocument.Styles("ListeNNN").Font
.Name = "Times New Roman"
.Size = 12
.UnderlineColor = wdColorAutomatic
.Color = wdColorAutomatic
.Scaling = 100
.Kerning = 0
.NumberSpacing = wdNumberSpacingDefault
.NumberForm = wdNumberFormDefault
.StylisticSet = wdStylisticSetDefault
.ContextualAlternates = 0
End With
With ActiveDocument.Styles("ListeNNN").ParagraphFormat
.LeftIndent = 38
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1.08)
.Alignment = wdAlignParagraphJustify
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = -31
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
.CollapsedByDefault = False
End With
ActiveDocument.Styles("ListeNNN").NoSpaceBetweenParagraphsOfSameStyle = True
ActiveDocument.Styles("ListeNNN").ParagraphFormat.TabStops.ClearAll
ActiveDocument.Styles("ListeNNN").LanguageID = wdFrench
ActiveDocument.Styles("ListeNNN").NoProofing = False
ActiveDocument.Styles("ListeNNN").Frame.Delete
'ListeNNNN
ActiveDocument.Styles.Add Name:="ListeNNNN", Type:=wdStyleTypeParagraph
ActiveDocument.Styles("ListeNNNN").AutomaticallyUpdate = False
With ActiveDocument.Styles("ListeNNNN").Font
.Name = "Times New Roman"
.Size = 12
.UnderlineColor = wdColorAutomatic
.Color = wdColorAutomatic
.Scaling = 100
.Kerning = 0
.NumberSpacing = wdNumberSpacingDefault
.NumberForm = wdNumberFormDefault
.StylisticSet = wdStylisticSetDefault
.ContextualAlternates = 0
End With
With ActiveDocument.Styles("ListeNNNN").ParagraphFormat
.LeftIndent = 38
.RightIndent = 0
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1.08)
.Alignment = wdAlignParagraphJustify
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = -38
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
.CollapsedByDefault = False
End With
ActiveDocument.Styles("ListeNNNN").NoSpaceBetweenParagraphsOfSameStyle = True
ActiveDocument.Styles("ListeNNNN").ParagraphFormat.TabStops.ClearAll
ActiveDocument.Styles("ListeNNNN").LanguageID = wdFrench
ActiveDocument.Styles("ListeNNNN").NoProofing = False
ActiveDocument.Styles("ListeNNNN").Frame.Delete
AppliqueNouveauxStyles
End Sub
Sub AppliqueNouveauxStyles()
Application.ScreenUpdating = False
Selection.HomeKey Unit:=wdStory
Dim Parag As Paragraph
Dim LeNumero
For Each Parag In ActiveDocument.Paragraphs
If Parag.Style = "Liste à numéros" Then
LeNumero = Val(Replace(Parag.Range.ListFormat.ListString, ".", ""))
If LeNumero > 9 And LeNumero < 100 Then
Parag.Range.Select
Selection.Style = ActiveDocument.Styles("ListeNN")
ElseIf LeNumero > 99 And LeNumero < 1000 Then
Parag.Range.Select
Selection.Style = ActiveDocument.Styles("ListeNNN")
ElseIf LeNumero > 999 And LeNumero < 10000 Then
Parag.Range.Select
Selection.Style = ActiveDocument.Styles("ListeNNNN")
End If
End If
Next Parag
Selection.HomeKey Unit:=wdStory
With ActiveDocument.Styles("Liste à numéros").Font
.Name = "Times New Roman"
.Size = 12
.Color = wdColorAutomatic
.Scaling = 100
.Kerning = 0
.NumberSpacing = wdNumberSpacingDefault
.NumberForm = wdNumberFormDefault
.StylisticSet = wdStylisticSetDefault
.ContextualAlternates = 0
End With
With ActiveDocument.Styles("Liste à numéros")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Liste à numéros"
End With
With ActiveDocument.Styles("Liste à numéros").ParagraphFormat
.LeftIndent = 38
.RightIndent = 0
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1.08)
.Alignment = wdAlignParagraphJustify
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = -17
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
.CollapsedByDefault = False
End With
Application.ScreenUpdating = True
End Sub