窗体中所有控件的属性,窗体中的控件属性能否更改

首页 > 实用技巧 > 作者:YD1662023-11-24 23:05:40

Sub 获取窗体中控件的属性列表()

On Error Resume Next

Dim 控件 As Object,数量 As Long,arr() As String

For Each 控件 In UserForm1.Controls

Dim 信息 As InterfaceInfo,mem As MemberInfo

Set 信息 = InterfaceInfoFromObject(控件) '从控件中获取属性

If Not (信息 Is Nothing) Then '如果有可以提取的信息

For Each mem In 信息.Members '遍历信息的子项

数量 = 数量 1

ReDim Preserve arr(1 TO 3,1 TO 数量)

arr(1,数量) = 控件.Name

arr(2,数量) = mem.Name

arr(3,数量) = callByName(控件,mem.name,vbget)

end if

next

end if

next

if 数量> 0 then

[a1:c1]=array("控件","属性","值")

[a2]=.resize(数量,3) = worksheet.function.transpose(arr)

columns("a:c").autofit

columns("a:c").horizontalalignment = xlleft

end if

end sub

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.