Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

List all procedures in a group

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
gwilym
Asked:
gwilym
  • 4
  • 3
  • 2
  • +2
1 Solution
 
shchukaCommented:
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
 
mcixCommented:
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
 
MirkwoodCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
fguerreiro_inixCommented:
You should give the point to mcix. The answer is correct or is a very good aproach.
0
 
gwilymAuthor Commented:
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
 
mcixCommented:
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
 
MirkwoodCommented:
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
 
gwilymAuthor Commented:
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
 
mcixCommented:
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
 
gwilymAuthor Commented:
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
 
mcixCommented:
Off the top of my head I don't know.

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now