Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Word > Contribuez
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 23/11/2007, 11h30   #1
Inactif
 
Avatar de ouskel'n'or
 
Inscription : février 2005
Messages : 12 466
Détails du profil
Informations forums :
Inscription : février 2005
Messages : 12 466
Points : 11 930
Points : 11 930
Par défaut Compter le ou les mots d'une liste ds un document et donner leurs N° de pages

Objet : Comptabiliser les mots d'une liste dans un texte et connaître les N° de pages dans lesquelles ils se trouvent
Code :
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
Sub ChercherTrouver()
Dim Recherche As Boolean
Dim TabloMots As Variant, TabloPages(), TabloQu(), i As Integer
Dim DerLigne As Byte
    TabloMots = Array("", "tata", "papa", "maman", "pépé", "mémé", "tonton", "michel")
    ReDim TabloPages(UBound(TabloMots))
    ReDim TabloQu(UBound(TabloMots))
    For i = 1 To UBound(TabloMots)
        Selection.HomeKey Unit:=wdStory
        With Selection.Find
            .Text = TabloMots(i)
            .MatchWholeWord = True 'recherche sur le mot entier (True par défaut)
            .Execute
            Recherche = .Found
        Do While Recherche
            TabloQu(i) = TabloQu(i) + 1
            TabloPages(i) = TabloPages(i) & "," & Selection.Information(wdActiveEndPageNumber)
            .Execute
            Recherche = .Found
        Loop
        End With
    Next
 
    'Affichage
    For i = 1 To UBound(TabloMots)
        If Not TabloQu(i) = Empty Then _
            MsgBox TabloMots(i) & " a été trouvé " & TabloQu(i) & " fois " & _
                       " pages " & Right(TabloPages(i), Len(TabloPages(i)) - 1)
    Next
End Sub
Pour faire une recherche sur toutes les occurences (mots cherchés contenus dans d'autres mots) mettre la propriété
Code :
      .MatchWholeWord = False
ouskel'n'or est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/12/2007, 16h10   #2
Inactif
 
Avatar de ouskel'n'or
 
Inscription : février 2005
Messages : 12 466
Détails du profil
Informations forums :
Inscription : février 2005
Messages : 12 466
Points : 11 930
Points : 11 930
But : Permettre la saisie du mot ou de la liste des mots à chercher
Code :
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 ChercherTrouver()
Dim Recherche As Boolean, UnMot as string
Dim TabloMots(), TabloPages(), TabloQu(), i As Integer
    Do
          UnMot = inputbox("Saisir un nouveau mot", "SAISIE de la LISTE","")
          if Trim(UnMot) <> "" then
                i = i + 1
                Redim Preserve TabloMots(i)
                TabloMots(i) = UnMot
          endif
    Loop while trim(UnMot) <> ""
    if i = 0 then exit sub
    ReDim TabloPages(UBound(TabloMots))
    ReDim TabloQu(UBound(TabloMots))
    For i = 1 To UBound(TabloMots)
        Selection.HomeKey Unit:=wdStory
        With Selection.Find
            .Text = TabloMots(i)
            .MatchWholeWord = True 'recherche sur le mot entier (True par défaut)
            .Execute
            Recherche = .Found
        Do While Recherche
            TabloQu(i) = TabloQu(i) + 1
            TabloPages(i) = TabloPages(i) & "," & Selection.Information(wdActiveEndPageNumber)
            .Execute
            Recherche = .Found
        Loop
        End With
    Next
 
    'Affichage
    For i = 1 To UBound(TabloMots)
        If Not TabloQu(i) = Empty Then _
            MsgBox TabloMots(i) & " a été trouvé " & TabloQu(i) & " fois " & _
                       " pages " & Right(TabloPages(i), Len(TabloPages(i)) - 1)
    Next
End Sub
ouskel'n'or est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h35.


 
 
 
 
Partenaires

Hébergement Web