首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

vbe操作

'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

  • 发表于:
  • 原文链接https://page.om.qq.com/page/OVni2NulauABH0KfsMsJP0eQ0
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券