How to list existing variables ?

G

Guest

Hello,

I wish to list the already defined Public Variables from VBA, just like I
list my existing tables. Is there a kind of "VariableDefs", like "TableDefs"
I could use ?

Thank you already for any help.
Nicodemus
 
S

Stefan Hoffmann

hi Nicodemus,
I wish to list the already defined Public Variables from VBA, just like I
list my existing tables. Is there a kind of "VariableDefs", like "TableDefs"
I could use ?
No, such a collection does not exists. Maybe there some tools which can
do that, but I don't know any.


mfG
--> stefan <--
 
M

Marshall Barton

Nicodemus said:
I wish to list the already defined Public Variables from VBA, just like I
list my existing tables. Is there a kind of "VariableDefs", like "TableDefs"
I could use ?


Here's the outline of a procedure that lists the plublic
decalarations in standard modules:


Public Sub ListGlobals()
Dim db As DAO.Database
Dim doc As Document
Dim mdl As Module
Dim LinePos As Long
Dim CodeLine As String
Dim StmtWordEnd As Long

Set db = CurrentDb()

For Each doc In db.Containers("Modules").Documents
DoCmd.OpenModule doc.Name
With Modules(doc.Name)
If .Type = acStandardModule Then

For LinePos = 1 To .CountOfDeclarationLines
CodeLine = Trim(.Lines(LinePos, 1))
If Len(CodeLine) > 4 Then
StmtWordEnd = InStr(CodeLine, " ")
If StmtWordEnd > 3 Then
Select Case Left(CodeLine,
StmtWordEnd - 1)
Case "Public", "Dim", "Global",
"Const"
Debug.Print .Name; Spc(5);
CodeLine
End Select
End If
End If
Next LinePos

End If
End With
'Don't close this module
If doc.Name <> "CountLinesOfCode" _
Then DoCmd.Close acModule, doc.Name, acSaveNo
Next doc
Set db = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top