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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
Dim chaine As String, tmp As String
Dim bool As Boolean
Dim start As Long
Dim occu As Integer
Dim nbOcc As Integer
Dim Plage As Object, Wrd As Object
Dim Cible As String
Private Sub BUT_Next_Click()
tmp = searchingForw()
End Sub
Private Sub BUT_Previous_Click()
tmp = searchingBack()
End Sub
Private Sub UserForm_Initialize()
count = 0
chaine = ActiveDocument.Range(Selection.start, Selection.End)
If Right(chaine, 1) = Chr(13) Then
MsgBox chaine & " !!"
chaine = Left(chaine, Len(chaine) - 1)
MsgBox chaine & " !!"
End If
chaine = Trim(chaine)
With ActiveDocument.Content.Find
Do While .Execute(findText:=chaine, Format:=False, MatchCase:=False, MatchWholeWord:=False) = True
count = count + 1
MsgBox count
Loop
End With
start = Selection.start
MsgBox start
If count = 0 Then
MsgBox "Veuillez sélectionner un texte"
Exit Sub
End If
End Sub
Function searchingForw()
ActiveWindow.LargeScroll (2)
ActiveWindow.ScrollIntoView Obj:=Selection.Range, start:=True
If ActiveWindow.Split = False Then
ActiveWindow.Split = True
End If
ActiveWindow.Panes(2).Activate
chaine = Trim(chaine)
'recherche notre mot
With Selection.Find
.ClearFormatting
.Text = chaine
.Forward = True
While .Execute
start = Selection.End + 1
.Wrap = wdFindAsk
Exit Function
Wend
End With
searchingForw = chaine
End Function
Function searchingBack()
ActiveWindow.LargeScroll (2)
ActiveWindow.ScrollIntoView Obj:=Selection.Range, start:=True
If ActiveWindow.Split = False Then
ActiveWindow.Split = True
End If
ActiveWindow.Panes(2).Activate
chaine = Trim(chaine)
'recherche notre mot
With Selection.Find
.ClearFormatting
.Text = chaine
.Forward = False
While .Execute
start = Selection.start - 1
.Wrap = wdFindAsk
Exit Function
Wend
End With
searchingBack = chaine
End Function
Private Sub BUT_Close_Click()
If ActiveWindow.Split Then
ActiveWindow.Panes(2).Close
End If
Unload Search
End Sub |
Partager