Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to list existing variables ?

0 views
Skip to first unread message

Nicodemus

unread,
Nov 12, 2007, 5:28:01 AM11/12/07
to
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

Stefan Hoffmann

unread,
Nov 12, 2007, 5:50:21 AM11/12/07
to
hi Nicodemus,

Nicodemus wrote:
> 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 <--

Marshall Barton

unread,
Nov 13, 2007, 2:00:56 PM11/13/07
to
Nicodemus wrote:
>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

--
Marsh
MVP [MS Access]

0 new messages