How many lines of code do I have?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    How many lines of code do I have?

    I was just asked an interesting question: How many lines of vba code do I have in my Access project?

    I didn't see any easy way to get this from the editor, and I don't know if it's possible to access the code in text form outside of Access. Anyone have a suggestion?
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    The MZ-Tools addin (freeware) offers a lot of documentation options, including, I believe, the total lines of code for an app.

    MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.


    Linq ;0)>

    Comment

    • ChipR
      Recognized Expert Top Contributor
      • Jul 2008
      • 1289

      #3
      Thanks for the link, Linq :)
      That looks like a nice option. Unfortunately for me, I can't use any unapproved programs, and approval takes a long time (from what I hear). Is there any way to get to my Access code in Visual Studio?

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #4
        Hi Chip. Investigate the use of the VBComponents collection of the Application.VBE object which is built-in to Access.

        For example, the following sub will list the names of the code modules in your current project and the number of lines in each to the immediate window:

        Code:
        Public Sub ModuleInfo()
            Dim basModule As VBComponent
            For Each basModule In Application.VBE.ActiveVBProject.VBComponents
                With basModule
                  Debug.Print .Name, .CodeModule.CountOfLines, .CodeModule.CountOfDeclarationLines
                End With
            Next basModule
        End Sub
        -Stewart

        Comment

        • ChipR
          Recognized Expert Top Contributor
          • Jul 2008
          • 1289

          #5
          Perfect! I knew there had to be a way, just never heard of that collection.
          Thanks, Stewart.

          Comment

          Working...