Option Explicit
Private Function FindReplace(Chaine As String) As String
Dim Pos As Long, Taille As Long
Dim strR As String, strL As String, Str As String
Dim Cpt As Long, Ch As String
Dim ChRecherchée As String
Cpt = 0
ChRecherchée = "&&"
Do
Pos = InStr(Chaine, ChRecherchée )
Taille = Len(Chaine)
If Pos > 0 Then
Cpt = Cpt + 1
Ch = "[" & Cpt & "]"
strL = Left(Chaine, Pos - 1)
strR = Right(Chaine, Taille - Pos - Len(ChRecherchée) + 1)
Str = strL & Ch & strR
Chaine = Str
End If
Loop Until Pos = 0
Application.StatusBar = "Nb Remplacement : " & Cpt
FindReplace = Chaine
End Function
Public Sub Remplacer()
Dim Str As String
ActiveDocument.Select
Str = Selection
Selection = FindReplace(Str)
Application.ScreenRefresh
End Sub
|