Deprecated: RegularLabs\Library\ArrayHelper::implode(): Implicitly marking parameter $last_glue as nullable is deprecated, the explicit nullable type must be used instead in /homepages/10/d550841420/htdocs/libraries/regularlabs/src/ArrayHelper.php on line 225
Comment extraire tous les textes entre parenthèses ?

Recherche

Voici une macro qui va créer un nouveau document dans lequel seront listées toutes les expressions entre parenthèses situées dans le document actif.

 

Sub parentheses2()

'macro écrite par m@rina
Dim texte As String, Liste As String, ND As Document

Application.ScreenUpdating = False
Selection.HomeKey unit:=wdStory

'Recherche de tous les textes entre parenthèses
    Do
        Selection.Find.ClearFormatting
        With Selection.Find
            .ClearFormatting
            .Text = "\(*\)"
            .Forward = True
            .Wrap = wdFindStop
            .MatchCase = True
            .MatchWildcards = True
            .Execute
        End With

    If Selection.Find.Found Then
        texte = ActiveDocument.Range(Selection.Range.Start + 1, Selection.Range.End - 1)
            If InStr(Liste, texte) = 0 Then
                Liste = Liste & texte & vbCr
            End If
        End If
    Loop Until Not Selection.Find.Found

'On crée le nouveau doc et on y insère les textes trouvés
    Set ND = Documents.Add
    Selection.TypeText Text:=Liste

End Sub

Statistiques

France 72,3% France
Canada 5,3% Canada
Chine 3,7% Chine

Total:

154

Pays
018457933
Aujourd'hui: 118
Hier: 236
Cette semaine: 118
Semaine dernière: 2.729
Ce mois: 5.861