Option Base 1
Sub Macrodate1()
'
mois = Array("janvier", "février", "mars", "avril", "mai", "juin", _
"juillet", "août", "septembre", "octobre", "novembre", "décembre")
Selection.Find.ClearFormatting
With Selection.Find
For i = 1 To 12
Selection.HomeKey Unit:=wdStory
Do
.ClearFormatting
.Text = "([0-9]{2})/" & IIf(i < 10, "0" & i, i) & "/([0-9]{4})"
.Forward = True
.Wrap = wdFindContinue
.MatchCase = True
.MatchWildcards = True
.Execute
If .Found = True Then
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=4, Extend:=wdExtend
Selection.TypeText Text:=" " & CStr(mois(i)) & " "
End If
Loop Until .Found = False
Next i
End With
End Sub
Pour la partie xx/xx/xxxx ça fonctionne moins un coquille; i.e le mois compte un mois de trop. Ce qui peut être corrigé par la ligne
Selection.TypeText Text:=" " & CStr(mois(i - 1)) & " "
si on veut rechercher 01/ ou bien 1/ comment konfé?
Option Base 1
Sub Macrodate1()
'
mois = Array("janvier", "février", "mars", "avril", "mai", "juin", _
"juillet", "août", "septembre", "octobre", "novembre", "décembre")
Selection.Find.ClearFormatting
With Selection.Find
For i = 1 To 12
Selection.HomeKey Unit:=wdStory
Do
.ClearFormatting
.Text = "([0-9]{1;})/" & IIf(i < 10, "0" & i, i) & "/([0-9]{4})"
.Forward = True
.Wrap = wdFindContinue
.MatchCase = True
.MatchWildcards = True
.Execute
If .Found = True Then
ddate = 10 - Len(Selection)
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=2 - ddate
Selection.MoveRight Unit:=wdCharacter, Count:=4, Extend:=wdExtend
Selection.TypeText Text:=" " & CStr(mois(i)) & " "
End If
Loop Until .Found = False
Next i
End With
End Sub