'ProcKindString根据过程类型值返回一个相应过程类型的字符串
Function strProcKind(ByVal ProcKind As vbext_ProcKind) As String
Select Case ProcKind
Case vbext_pk_Get
strProcKind = "Property Get"
Case vbext_pk_Let
strProcKind = "Property Let"
Case vbext_pk_Set
strProcKind = "Property Set"
Case vbext_pk_Proc
strProcKind = "Sub/Function"
End Select
End Function
'GetProcInModule获取指定工作簿中指定组件代码模块中的所有过程名称
Function strGetProcInfor(ByVal wkbWork As Workbook, _
ByVal strComponent As String) As String
Dim ProcKind As vbext_ProcKind
Dim lngLineNum As Long
Dim lngProcLine As Long
Dim strMsg As String
Dim strProcName As String
With wkbWork.VBProject.VBComponents(strComponent).CodeModule
lngLineNum = .CountOfDeclarationLines + 1
Do Until lngLineNum >= .CountOfLines
strProcName = .ProcOfLine(lngLineNum, ProcKind)
lngProcLine = .ProcCountLines(strProcName, ProcKind)
strMsg = strMsg & strProcName & ": " & lngProcLine _
& ", " & strProcKind(ProcKind) & vbLf
lngLineNum = lngProcLine + lngLineNum
Loop
End With
strGetProcInfor = strMsg
End Function
Sub PrintProcInfor()
Debug.Print strGetProcInfor(ThisWorkbook, "mdlListProc")
End Sub
Sub GetVBComponentsInfo()
Dim objVBComp As Object
Dim strVBCompType As String
Dim i As Long
i = 1
Range("A1:C1") = Array("部件名称", "部件类型", "代码行数")
For Each objVBComp In ThisWorkbook.VBProject.VBComponents
With objVBComp
Select Case .Type
Case vbext_ct_Document
strVBCompType = "Microsoft Excel 对象"
Case vbext_ct_StdModule
strVBCompType = "标准模块"
Case vbext_ct_MSForm
strVBCompType = "用户窗体"
Case vbext_ct_ClassModule
strVBCompType = "类模块"
End Select
i = i + 1
Cells(i, 1) = .Name
Cells(i, 2) = strVBCompType
Cells(i, 3) = .CodeModule.CountOfLines
End With
Next objVBComp
Set objVBComp = Nothing
End Sub
Sub ClearDAta()
Range("A:C").ClearContents
End Sub
Sub GetVBComponentsInfo()
Dim objVBComp As Object
Dim strVBCompType As String
Dim i As Long
i = 1
Range("A1:C1") = Array("部件名称", "部件类型", "代码行数")
For Each objVBComp In ThisWorkbook.VBProject.VBComponents
With objVBComp
Select Case .Type
Case vbext_ct_Document
strVBCompType = "Microsoft Excel 对象"
Case vbext_ct_StdModule
strVBCompType = "标准模块"
Case vbext_ct_MSForm
strVBCompType = "用户窗体"
Case vbext_ct_ClassModule
strVBCompType = "类模块"
End Select
i = i + 1
Cells(i, 1) = .Name
Cells(i, 2) = strVBCompType
Cells(i, 3) = .CodeModule.CountOfLines
End With
Next objVBComp
Set objVBComp = Nothing
End Sub
Sub ClearDAta()
Range("A:C").ClearContents
End Sub
Sub GetVBComponentsInfo()
Dim objVBComp As Object
Dim strVBCompType As String
Dim i As Long
i = 1
Range("A1:C1") = Array("部件名称", "部件类型", "代码行数")
For Each objVBComp In ThisWorkbook.VBProject.VBComponents
With objVBComp
Select Case .Type
Case vbext_ct_Document
strVBCompType = "Microsoft Excel 对象"
Case vbext_ct_StdModule
strVBCompType = "标准模块"
Case vbext_ct_MSForm
strVBCompType = "用户窗体"
Case vbext_ct_ClassModule
strVBCompType = "类模块"
End Select
i = i + 1
Cells(i, 1) = .Name
Cells(i, 2) = strVBCompType
Cells(i, 3) = .CodeModule.CountOfLines
End With
Next objVBComp
Set objVBComp = Nothing
End Sub
Sub ClearDAta()
Range("A:C").ClearContents
End Sub
领取专属 10元无门槛券
私享最新 技术干货