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
|
Private Sub Noms_Modules()
Dim CollectionModule As Object
Dim Module As Object
Dim Tbl
Dim Ligne As String
Dim Pos As Integer
Dim I As Integer
Dim J As Integer
Dim K As Integer
Dim L As Integer
On Error Resume Next
'défini dans un tableau les mots à chercher
Tbl = Array("Sub", _
"Function", _
"Public", _
"Global", _
"Private", _
"Dim", _
"Static")
Set CollectionModule = ActiveWorkbook.VBProject.VBComponents
For Each Module In CollectionModule
K = K + 1
L = L + 1
'inscrit le nom du module en colonne A
Cells(K, 1) = Module.Name
Cells(K, 1).Font.Bold = True
Cells(K, 2) = "Variables"
Cells(K, 3) = "Sub/Function"
'recherche les lignes commençant par les noms du tableau et les inscrit
'en colonne B. C'est une moulinette qui passe tous les noms du tableau
'et toutes les lignes
For I = 0 To UBound(Tbl)
For J = 1 To Module.CodeModule.CountOfLines
Ligne = Trim(Module.CodeModule.Lines(J, 1))
Pos = InStr(Ligne, Tbl(I))
If Pos = 1 Then
'si c'est une variable
If InStr(Ligne, "Sub") = 0 And InStr(Ligne, "Function") = 0 Then
K = K + 1
Cells(K, 2) = Ligne
'si c'est une Sub ou Function
Else
L = L + 1
Cells(L, 3) = Ligne
End If
End If
Next J
Next I
Next
Set CollectionModule = Nothing
Set Module = Nothing
Erase Tbl
End Sub |
Partager