Bonjour,
j'ai écrit une macro qui doit rechercher une expression et la mettre en gras, puis s'arrêter à la fin du document. La voici:
J'ai du me tromper quelque part puisque j'effectue une boucle infinie.
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
38
39
40
41
42 Private Sub Test() Selection.HomeKey unit:=wdStory MiseEnGras ("Mon expression :") End Sub Function MiseEnGras(expression As String) Selection.HomeKey unit:=wdStory Do While (RechercheExpressionArretFinDoc(expression) <> False) Selection.EndKey unit:=wdLine, Extend:=wdExtend Selection.Font.Bold = True Loop End Function Function RechercheExpressionArretFinDoc(expression As String) Selection.Find.ClearFormatting With Selection.Find .Text = expression .Forward = True ' on s'arrete à la fin du document .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = True .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False End With If (Selection.Find.Execute = False) Then RechercheExpressionArretFinDoc = False Else RechercheExpressionArretFinDoc = True End If End Function
Quelqu'un voit-il l'erreur?
Merci.
Partager