Superpat
Member
- Local time
- Today, 18:49
- Joined
- Aug 15, 2020
- Messages
- 105
Hello,
I have two options to list module name :
The first list only the current module of the database, the second can list module outside of the database open.
Is there a solution to list the current module or an exterior module with the same code.
I have two options to list module name :
The first list only the current module of the database, the second can list module outside of the database open.
Is there a solution to list the current module or an exterior module with the same code.
Code:
Public Sub listSubFuncVBA10(PathBase As String)
'listSubFuncVBA10("D:\Dropbox\Access\Travail\OK\Nav_Courant_10-20.accdb")
'Ne peut lister que le module courant
Dim i As Long, j As Long, m As Long
Dim lngCount As Long ' Nombre de ligne du module
Dim sModules As String
For i = 1 To Application.VBE.VBProjects(1).VBComponents.Count
' Nom du Formulaire, du Report, du Module
sModules = Application.VBE.VBProjects(1).VBComponents.Item(i).Name
Debug.Print vbCrLf & i & " " & Application.VBE.VBProjects(1).VBComponents.Item(i).Name
' Nombre de ligne du module.
lngCount = Application.VBE.VBProjects(1).VBComponents.Item(i).CodeModule.CountOfLines
Debug.Print " Nombre de lignes dans le module " & sModules & " : " & lngCount
' Nombre de ligne dans la section déclaration du module.
' On boucle pour donner le nom des modules
Next
End Sub
Code:
Function Liste_Procedures_Fonctions_VBA10(PathBase As String) As Boolean
'?Liste_Procedures_Fonctions_VBA10("D:\Dropbox\Access\Travail\OK\Nav_Courant_10-20.accdb")
'?Liste_Procedures_Fonctions_VBA10("D:\Dropbox\Access\Travail\OK\Variables\variables - 2.accdb")
'On ne peut lister qu'un module exterieur
'Dim strSQL As String
Dim Accmodule As Module
Dim i As Integer
Dim oAccess As New Access.Application
On Error GoTo Fin
With oAccess
.Visible = False
.OpenCurrentDatabase (PathBase)
End With
For i = 1 To oAccess.VBE.VBProjects(1).VBComponents.Count
With oAccess.VBE.VBProjects(1).VBComponents.Item(i).CodeModule
Debug.Print oAccess.VBE.VBProjects(1).VBComponents.Item(i).CodeModule
'Debug.Print oAccess.VBE.VBProjects(1).VBComponents.Count
Debug.Print oAccess.VBE.VBProjects(1).VBComponents.Item(i).CodeModule.CountOfLines
End With
Next i
MsgBox "Fin : " & i
oAccess.DoCmd.Close , , acSaveYes
Set oAccess = Nothing
Exit Function
Fin:
Resume Next
End Function