Solved

List all procedures in a group

Posted on 1998-10-12
11
299 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
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.

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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