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
| Sub pararech()
Dim rangepremot As Range
Dim rangesecmot As Range
Dim indexparamot1 As Long
Dim indexparamot2 As Long
Set rangepremot = ActiveDocument.Range
Set rangesecmot = ActiveDocument.Range
With rangepremot.Find
.Text = "mot1"
.Execute
End With
With rangesecmot.Find
.Text = "mot2"
.Execute
End With
rangepremot.Select
Selection.MoveRight Count:=1
Selection.HomeKey wdStory, wdExtend
indexparamot1 = Selection.Paragraphs.Count
rangesecmot.Select
Selection.MoveRight Count:=1
Selection.HomeKey unit:=wdStory, Extend:=wdExtend
indexparamot2 = Selection.Paragraphs.Count
If indexparamot1 = indexparamot2 Then
MsgBox "même paragraphe"
End If
Set rangepremot = Nothing
Set rangesecmot = Nothing
End Sub |
Partager