利用TypeLib Information枚举对象属性、利用CallByName反射调用函数
'引用TypeLib Information Sub listcontrols() Cells(1, 1) = "控件" Cells(1, 2) = "属性,方法,事件" Cells(1, 3) = "值" [a1:c1].Interior.ColorIndex = 3 On Error Resume Next Dim ctl As Object, n As Long n = 1 For Each ctl In UserForm1.Controls Dim iInf As InterfaceInfo Set iInf = InterfaceInfoFromObject(ctl) If Not (iInf Is Nothing) Then Dim mem As MemberInfo For Each mem In iInf.Members If mem.InvokeKind Then n = n + 1 Cells(n, 1) = ctl.Name Cells(n, 2) = mem.Name Cells(n, 3) = CallByName(ctl, mem.Name, VbGet) End If Next End If Next [a1:c65536].Columns.AutoFit End Sub
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛