Solved

List all procedures in a group

Posted on 1998-10-12
11
290 Views
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!
0
Comment
Question by:gwilym
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 2

Expert Comment

by:shchuka
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.
0
 
LVL 4

Expert Comment

by:mcix
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
         Next
      Next
   Next

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)
0
 
LVL 13

Expert Comment

by:Mirkwood
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.
0
 
LVL 3

Expert Comment

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

Author Comment

by:gwilym
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 g.ellis@dial.pipex.com 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 ...'!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:mcix
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...
 
marko_justus@hotmail.com

0
 
LVL 13

Expert Comment

by:Mirkwood
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
    Next
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
    Next
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)
    Next
End Sub


0
 

Author Comment

by:gwilym
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?
0
 
LVL 4

Accepted Solution

by:
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...

0
 

Author Comment

by:gwilym
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)
0
 
LVL 4

Expert Comment

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

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now