Bonjour,

Je n'arrive pas a résoudre mon problème de nombre de caractères dans la déclaration de variable "variant"

erreur d'execution : chaine de caractère trop longue au niveau de
Code : Sélectionner tout - Visualiser dans une fenêtre à part
       .Replacement.Text = texte_de_remplacement
voici le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Sub Word_Remplacer_texte(Texte_à_remplacer As Variant, texte_de_remplacement As Variant, Tout As Boolean, Optional taille As Byte)
 
Dim old_taille As Byte
'chargement des paramètre
old_taille = Word_Application.Selection.Font.Size
 
With Word_Application
    .Selection.Find.ClearFormatting
    .Selection.Find.Replacement.ClearFormatting
    With .Selection.Find
        .Text = Texte_à_remplacer
        .Replacement.Text = texte_de_remplacement
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    .Selection.Find.Execute
    With .Selection
        If taille > 0 Then Word_Application.Selection.Font.Size = taille
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseStart
        Else
            .Collapse Direction:=wdCollapseEnd
        End If
        If Tout Then
            .Find.Execute Replace:=wdReplaceAll
        Else
            .Find.Execute Replace:=wdReplaceOne
        End If
    End With
End With
End Sub