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
| Sub Cherchons_Remplacons()
Datext = Selection.Text
'Motcher=mot à remplacer
Motcher = "1.9"
'ctr=compteur
ctr = 0
Pos = 0
Do
Pos = InStr(1, Datext, Motcher, 1)
'Chaîne non trouvée.
If Pos = 0 Then
Exit Do
End If
'ctr = nombre d'occurrences
ctr = ctr + 1
Datext = Right(Datext, Len(Datext) - Pos)
Loop While (ctr > 0 And Len(Datext) > Len(Motcher))
MsgBox ctr
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "1.9"
.Replacement.Text = "1,9"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub |
Partager