onjour,
Je voudrai remplacer des mots dans un texte à partir de 2 listes de mots obtenus depuis access. Il y a deux cas possibles : certains mots sont à supprimer directement, d'autres mots sont à colorer puis à supprimer manuellement en fonction du contexte.
Je suis débutant sur le vba...
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 Public Sub supprime() Dim oWord As Word.Application Dim oDoc As Word.Document Dim db As DAO.Database Dim rsasup As DAO.Recordset Dim rsavoir As DAO.Recordset Set oWord = ?? Set db = CurrentDb Set rsasup = db.OpenRecordset("SELECT mots FROM MOTS_SORTIS WHERE nom_ent = 0") While Not rsasup.EOF With Word_Application .Selection.Find.ClearFormatting .Selection.Find.Replacement.ClearFormatting With .Selection.Find .Text = rsasup .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With .Selection.Find.Execute rsasup.MoveNext Wend rsasup.Close Set rsasup = Nothing Set rsavoir = db.OpenRecordset("SELECT mots FROM MOTS_SORTIS WHERE nom_ent = -1") While Not rsavoir.EOF With Word_Application .Selection.Find.ClearFormatting .Selection.Find.Replacement.ClearFormatting With .Selection.Find .Text = rsasup .Forward = True .Wrap = wdFindContinue .Format = False .Font.Color = wdColorRed .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With .Selection.Find.Execute rsavoir.MoveNext Wend rsavoir.Close Set rsavoir = Nothing db.Close Set db = Nothing oWord.Quit End Sub
Partager