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
| Sub SelectdeuxMLigne()
'
'affectation de la page courante
Sectnr = InputBox("Indiquez le numéro de SECTION pour le début de l'exécution de la macro (Prise en compte Page de garde + TOC)" & vbCrLf & vbCrLf & _
"Entrez un nombre entier", "forum Access")
'affectation du nombre de pages du document
TotSections = ActiveDocument.Sections.Count
'initialisation de la ligne previous à 'Table 0' par exemple
TextL2Previous = "Table 0"
' boucle de section en section
For inti = Sectnr To Sectnr Step 1
Debug.Print inti
Dim TextL2Current As String
' position sur la ligne n°2
Selection.MoveDown wdLine, 1
Selection.HomeKey wdLine
Selection.EndKey wdLine, wdExtend
TextL2Current = Selection.Text
MsgBox TextL2Current
' Comparaison des deux variables (Retourne 0 si identiques)
TextComp = StrComp(TextL2Current, TextL2Previous, CompareMethod.Text)
' Si différentes alors sélectionner et changer le style en Heading 1 pour la ligne courante
If TextComp <> 0 Then
Selection.Style = ActiveDocument.Styles("Heading 1")
Next inti
TextL2Previous = TextL2Current
End Sub |
Partager