Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://bettersolutions.com/vba/visual-basic-editor/extensibility-sample-code.htm

Public Sub GetTTLLinesOfCode()
 Dim TTLLinesOfCode As Long
 TTLLinesOfCode = TotalLinesOfCodeInMacroWorkbook
 Debug.Print TTLLinesOfCode
End Sub
Public Function TotalLinesOfCodeInMacroWorkbook() As Long
 Dim basModule As VBComponent
 TotalLinesOfCodeInMacroWorkbook = 0
 For Each basModule In Application.VBE.ActiveVBProject.VBComponents
  With basModule
   'Debug.Print .Name, .CodeModule.CountOfLines, .CodeModule.CountOfDeclarationLines
   TotalLinesOfCodeInMacroWorkbook = TotalLinesOfCodeInMacroWorkbook + .CodeModule.CountOfLines
  End With
 Next basModule
End Function
  • No labels