|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
修改的northwolves版主的代码,枚举控件的事件、方法、属性、值,代码如下:
- Sub listcontrols()
- 'VBE界面,工具菜单--->引用--->浏览---->找到 C:\WINDOWS\system32\TLBINF32.DLL 打开即可。或者
- 'VBE界面,工具菜单--->引用--->下拉找到 TypeLib Information-->打勾即可 Cells(1, 1) = "控件"
- Set d = CreateObject("Scripting.Dictionary")
- Cells(1, 1) = "控件名称"
- Cells(1, 2) = "常量"
- Cells(1, 3) = "事件"
- Cells(1, 4) = "方法"
- Cells(1, 5) = "Get属性"
- Cells(1, 6) = "Let属性"
- Cells(1, 7) = "Set属性"
- Cells(1, 8) = "未知属性"
- Cells(1, 9) = "值"
- [a1:i1].Interior.ColorIndex = 3
- On Error Resume Next
- Dim ctl As Object, iInf, n As Long, m(1 To 5) As Long, max As Long
- Set ctl = CreateObject("scriptcontrol")
- Set y = CreateObject("TLI.TLIApplication")
- n = 1
- For Each ctl In UserForm1.Controls
- Set iInf = y.InterfaceInfoFromObject(ctl)
- If Not (iInf Is Nothing) Then
- Dim mem
- d.RemoveAll
- max = 0
- For i = 1 To 5
- If m(i) > max Then
- max = m(i)
- End If
- Next i
- For i = 1 To 5
- m(i) = max + 1
- Next i
- For Each mem In iInf.Members
- n = n + 1
-
- Select Case mem.InvokeKind
- Case TLI.INVOKE_CONST '常量
- m(1) = m(1) + 1
- Cells(m(1), 1) = ctl.Name
- Cells(m(1), 2) = mem.Name
- Case TLI.INVOKE_EVENTFUNC '事件
- m(2) = m(2) + 1
- Cells(m(2), 1) = ctl.Name
- Cells(m(2), 3) = mem.Name
- Case TLI.INVOKE_FUNC '方法
- m(3) = m(3) + 1
- Cells(m(3), 1) = ctl.Name
- Cells(m(3), 4) = mem.Name
- Case TLI.INVOKE_PROPERTYPUT 'Let属性
- If Not d.Exists(mem.Name) Then
- m(4) = m(4) + 1
- d(mem.Name) = m(4)
- Cells(m(4), 1) = ctl.Name
- Cells(m(4), 5) = mem.Name
- Else
- Cells(d(mem.Name), 1) = ctl.Name
- Cells(d(mem.Name), 5) = mem.Name
- End If
- Case TLI.INVOKE_PROPERTYPUTREF 'Set属性
- If Not d.Exists(mem.Name) Then
- m(4) = m(4) + 1
- d(mem.Name) = m(4)
- Cells(m(4), 1) = ctl.Name
- Cells(m(4), 6) = mem.Name
- Else
- Cells(d(mem.Name), 1) = ctl.Name
- Cells(d(mem.Name), 6) = mem.Name
- End If
- Case TLI.INVOKE_PROPERTYGET 'Get属性
- If Not d.Exists(mem.Name) Then
- m(4) = m(4) + 1
- d(mem.Name) = m(4)
- Cells(m(4), 1) = ctl.Name
- Cells(m(4), 7) = mem.Name
- Else
- Cells(d(mem.Name), 1) = ctl.Name
- Cells(d(mem.Name), 7) = mem.Name
- End If
- Case TLI.INVOKE_UNKNOWN '未知
- m(5) = m(5) + 1
- Cells(m(5), 1) = ctl.Name
- Cells(m(5), 8) = mem.Name
- End Select
- Cells(m(4), 9) = CallByName(ctl, mem.Name, VbGet)
- Next
- End If
- Next
- [a1:c65536].Columns.AutoFit
- End Sub
复制代码
|
|