View Single Post
 
Old 12-04-2020, 04:50 AM
jpl jpl is offline Windows 7 64bit Office 2010 32bit
Advanced Beginner
 
Join Date: Jan 2016
Location: France
Posts: 33
jpl is on a distinguished road
Default

ceci a l'air de fonctionner, à tester !
Code:
Sub Essai()
  Dim i As Long, Trouvé As String, ListeTrouvés As String, Prefixes As Variant, Total As Long
  ListeTrouvés = " "
  Prefixes = Array("PE-", "JEB-", "HEL-")
  For i = 0 To UBound(Prefixes)

    With ActiveDocument.Content.Find
      .ClearFormatting
      .MatchWildcards = True
      .Text = Prefixes(i) & "[0-9]{1;}"
      .Forward = True
      .Execute

      Do While .Found
        Trouvé = .Parent.Text
        If InStr(1, ListeTrouvés, Trouvé & " ") = 0 Then
          ListeTrouvés = ListeTrouvés & Trouvé & " "
          Total = Total + 1
        End If
        .Execute
      Loop

    End With
  Next i
  ListeTrouvés = Trim(ListeTrouvés)
  ListeTrouvés = Replace(ListeTrouvés, " ", Chr(13))
  Debug.Print ListeTrouvés
  Debug.Print "Total = " & Total
End Sub
Reply With Quote