List all procedures in a group

Posted on 1998-10-12
Last Modified: 2010-04-30
I have a very large group containing a number of projects, each with many forms, modules, class modules etc.  I want a list of all the procedures  - that's all the subs, properties and methods.  How should I do this?  Using VBIDE, by analyzing the files as text files, or is there a standard VB feature that I don't know of to do this for me?

Answers with working sample code please!
Question by:gwilym
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2

Expert Comment

ID: 1439361
You can use Object Browser (from View menu or by pressing F2 key).  In the upper combo box select the name of your project.  After that, the left list will contain the list of your forms/modules/classes and after clicking on one of them, the right pane will list the procedures/functions in the selected module.

Expert Comment

ID: 1439362
You could create an Add-In and reference the VBIDE something like this:

   Dim mvbProject As vbProject
   Dim mvbComponent As VBComponent
   Dim mvbCodeModule As CodeModule
   Dim mvbCodePane As CodeModule
   Dim mvbMember As Member

   For Each mvbProject In VBInstance.VBProjects
      MsgBox mvbProject.Name
      For Each mvbComponent In mvbProject.VBComponents
         MsgBox mvbComponent.Name
         For Each mvbMember In mvbComponent.CodeModule.Members
             MsgBox mvbMember.Name & " - " & mvbMember.Type

This will list all:

1. All Projects in the Open Group
2. All Forms,Modules and Classes in each Project
3. All properties, methods and members in each Form, Module or Class

It's a starting point for what you want to do. (I think)
LVL 13

Expert Comment

ID: 1439363
Give me your email address and i'll mail you an add-in dll that does that or raise the points to 300 and award with an A and I will mail you the source of an add-in that does that.
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.


Expert Comment

ID: 1439364
You should give the point to mcix. The answer is correct or is a very good aproach.

Author Comment

ID: 1439365
Err .. thanks for the tip about the object browser.  I did know that one!  I need all the subs in all the projects, returned to code or a text file or something that I can manipulate for reports etc.  For mcix's code - what is VBInstance?  I couldn't see it listed under VBIDE, so I couldn't get the fragment to workas it just said unknown type.  I've seen it mentioned in relation ot AddIns, but have no experience of them - I tried creating one with that fragment in but to no joy.  What am I doing wrong to stop it working?  I'm at if anyone feels like mailing sample code/a working VB project (writing the results out to an .xls would be just perfect!) because you could reach the dimbot stage with me where every time you tell me how to do it I mail back 'I can't get it to work ...'!

Expert Comment

ID: 1439366
When you create an Add-In from the Add-In Template (VB5), it creates a project with the following declarations:

Public VBInstance As VBIDE.VBE
Public Connect As Connect

Connect is a class that is also created.

To use the code I provided,

1. Create an Add-In Project
2. On the Form it Creates, there will be an OK button
   Paste the code in the OKButton_Click paste the code.
3. In the Immediate Window, Type AddToINI
4. Run the Project

5. Open a New Instance of VB
6. From the Add-In Menu, Add-In Manager...
   Select MyAddIn
7. This should display a form with an OK and Cancel Button
8. Click On OK
   You should get a series of ListBoxes.

I will look into making it more into a working example for you...
It might make more sense to put the results in an Access Database instead of an Excel spreadsheet.  Atleast that is my thinking...

LVL 13

Expert Comment

ID: 1439367
Implements IDTExtensibility

Private Sub Class_Initialize()
    Load Form1
End Sub

Private Sub Class_Terminate()
    Unload Form1
    Set Form1 = Nothing
End Sub

Private Sub IDTExtensibility_OnAddInsUpdate(custom() As Variant)
End Sub

Private Sub IDTExtensibility_OnConnection(ByVal VBInst As Object, ByVal ConnectMode As VBIDE.vbext_ConnectMode, ByVal AddInInst As VBIDE.AddIn, custom() As Variant)
    Set Form1.m_vbe = VBInst
    Form1.Show vbModal
End Sub

Private Sub IDTExtensibility_OnDisconnection(ByVal RemoveMode As VBIDE.vbext_DisconnectMode, custom() As Variant)
    Set Form1.m_vbe = Nothing
End Sub

Private Sub IDTExtensibility_OnStartupComplete(custom() As Variant)
End Sub

---- End Class---------------------------------------------------------------------
--- Begin form1
Public m_vbe As VBIDE.vbe

Private Sub Command1_Click()
    AddProjects m_vbe
End Sub

Private Sub AddProjects(ByVal vbe As VBIDE.vbe)
    Dim vbp As VBIDE.VBProject
    Dim tve As Node
    For Each vbp In vbe.VBProjects
        Set tve = TreeView1.Nodes.Add(, , , vbp.Name)
        AddProjectComponents vbp, tve
End Sub

Private Sub AddProjectComponents(ByVal vbp As VBIDE.VBProject, ByVal parenttve As Node)
    Dim vbc As VBIDE.VBComponent
    Dim tve As comctllib.Node
    For Each vbc In vbp.VBComponents
        Set tve = TreeView1.Nodes.Add(parenttve, tvwChild, , vbc.Name)
        AddComponentFunctions vbc, tve
End Sub

Private Sub AddComponentFunctions(ByVal vbc As VBIDE.VBComponent, ByVal parenttve As Node)
    Dim tve As comctllib.Node
    Dim vbm As VBIDE.Member
    For Each vbm In vbc.CodeModule.Members
        Set tve = TreeView1.Nodes.Add(parenttve, tvwChild, , vbm.Name)
End Sub


Author Comment

ID: 1439368
I'd like to accpet mcix's comment as an answer if you can submit it as such - nothing personal, of the ones here and the ones I got mailed it was the one that I got to work straight off.  With one exception - it doesn't list all the subs.  The group that I used it on is very large - about 11 meg - and for, for instance, one of the classes which has about 60 public subs iterating through the collections described only returns three of them.  For certain modules it works fine and lists all of them.  Why is this?  Is it just VB being crap, or am I doing something wrong?

Accepted Solution

mcix earned 200 total points
ID: 1439369
I will look into that SUB problem, I am using this particular method for an Add-In myself and I haven't had that problem.

I am glad it's kind of working for you...


Author Comment

ID: 1439370
It did actually work fine.  I think the missing info was just a VB problem - restarting everything solved it and now it works every time, so maybe it was just the very large size of some of the modules that caused the problem.  PS - do you know which property of vbMember will give me the parameters of all the methods that your code lists?  (if necessary I can post this as a seperate Q)

Expert Comment

ID: 1439371
Off the top of my head I don't know.

Post as a new question and maybe someone will...

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question