Count of lines programmed

  • Thread starter Thread starter Dean Slindee
  • Start date Start date
D

Dean Slindee

Is there a way to determine how many lines of "programmer" custom code are
in an .adp without manually counting them?



Thanks,

Dean Slindee
 
Dean said:
Is there a way to determine how many lines of "programmer" custom code are
in an .adp without manually counting them?



I don't think an ADP would be any different from this MDB
code I use:

Public Function LinesOfCode() As Long
Dim dbCur As Database
Dim doc As Document

Set dbCur = CurrentDb
' Count lines of code in Modules
For Each doc In dbCur.Containers("Modules").Documents
DoCmd.OpenModule doc.Name
LinesOfCode = LinesOfCode + _
Modules(doc.Name).CountOfLines
DoCmd.Close acModule, doc.Name, acSaveNo
Next doc
' Count lines of code in Forms
For Each doc In dbCur.Containers("Forms").Documents
DoCmd.OpenForm doc.Name, acDesign
With Forms(doc.Name)
If .HasModule Then
LinesOfCode = LinesOfCode + _
.Module.CountOfLines
End If
End With
DoCmd.Close acForm, doc.Name, acSaveNo
Next doc
' Count lines of code in Reports
For Each doc In dbCur.Containers("Reports").Documents
DoCmd.OpenReport doc.Name, acDesign
With Reports(doc.Name)
If .HasModule Then
LinesOfCode = LinesOfCode + _
.Module.CountOfLines
End If
End With
DoCmd.Close acReport, doc.Name, acSaveNo
Next doc

Set dbCur = Nothing
End Function
 
An ADP is different - CurrentDb returns Nothing in an ADP - but with the
following few modifications Marshall's code can work with an ADP ...

Public Function LinesOfCode() As Long
'Dim dbCur As Database
'Dim doc As Document
Dim doc As AccessObject
'Set dbCur = CurrentDb

' Count lines of code in Modules
'For Each doc In dbCur.Containers("Modules").Documents
For Each doc In CurrentProject.AllModules
DoCmd.OpenModule doc.Name
LinesOfCode = LinesOfCode + _
Modules(doc.Name).CountOfLines
DoCmd.Close acModule, doc.Name, acSaveNo
Next doc
' Count lines of code in Forms
'For Each doc In dbCur.Containers("Forms").Documents
For Each doc In CurrentProject.AllForms
DoCmd.OpenForm doc.Name, acDesign
With Forms(doc.Name)
If .HasModule Then
LinesOfCode = LinesOfCode + _
.Module.CountOfLines
End If
End With
DoCmd.Close acForm, doc.Name, acSaveNo
Next doc
' Count lines of code in Reports
'For Each doc In dbCur.Containers("Reports").Documents
For Each doc In CurrentProject.AllReports
DoCmd.OpenReport doc.Name, acDesign
With Reports(doc.Name)
If .HasModule Then
LinesOfCode = LinesOfCode + _
.Module.CountOfLines
End If
End With
DoCmd.Close acReport, doc.Name, acSaveNo
Next doc

'Set dbCur = Nothing
End Function
 
Thanks for adding this Brendan.

I guess I should know what CurrentProject is even if I don't
do ADP ;-)
 
Back
Top