|
- Sub Main()
- Dim VBP As VBIDE.VBProject
- Dim VBC As VBComponent
- Dim CM As CodeModule
- Dim Msg As String
- Dim StartLine As Long, Cnt As Long
-
- Set VBP = ActiveWorkbook.VBProject 'ActiveWorkbook改为要统计的工作簿名
-
- For Each VBC In VBP.VBComponents
- Set CM = VBC.CodeModule
- StartLine = CM.CountOfDeclarationLines + 1
- Do Until StartLine >= CM.CountOfLines
- '显示过程名称,可删除
- Msg = Msg & VBC.Name & ":" & CM.ProcOfLine(StartLine, vbext_pk_Proc) & vbNewLine
- '过程数量
- Cnt = Cnt + 1
- StartLine = StartLine + _
- CM.ProcCountLines(CM.ProcOfLine(StartLine, vbext_pk_Proc), vbext_pk_Proc)
- Loop
- Next VBC
- Msg = Msg & vbCrLf & "过程总数:" & Cnt
- MsgBox Msg
- End Sub
复制代码 |
|