VBA 在运行时向用户窗体添加用户定义的控件
VBA Adding a User Defined Control to Userform at Runtime
所以我在设计模式下制作了以下控件,然后将控件添加到我工具箱中的新页面 Custom
。
现在,Controls.Add()
中的 progID
参数应该用什么?我如何查找这个值? Controls.Add("Forms.Frame.1")
添加常规框架,而不是所需的自定义控件。
据我所知,您没有使用自定义控件生成新的 progID。根据 MSDN documentation for custom/modified 控件:
Note: When you drag a control onto the Control Toolbox, you only transfer the advanced property values.
所以只转移了属性;实际控件仍然与您创建它的控件相同 type/s。此外,看起来这个 progID 是 "a unique system-wide string that the Windows operating system can use to identify your control's type." 因此,除非您准备编写自己的控件,否则看起来您只是将属性传递给您在那里创建的自定义工具箱控件。
您每次要添加自定义控件时都必须复制它。只需创建一个具有所有正确属性的 sub 并调用它。不是您想要的,但它会完成工作。
所以我在设计模式下制作了以下控件,然后将控件添加到我工具箱中的新页面 Custom
。
现在,Controls.Add()
中的 progID
参数应该用什么?我如何查找这个值? Controls.Add("Forms.Frame.1")
添加常规框架,而不是所需的自定义控件。
据我所知,您没有使用自定义控件生成新的 progID。根据 MSDN documentation for custom/modified 控件:
Note: When you drag a control onto the Control Toolbox, you only transfer the advanced property values.
所以只转移了属性;实际控件仍然与您创建它的控件相同 type/s。此外,看起来这个 progID 是 "a unique system-wide string that the Windows operating system can use to identify your control's type." 因此,除非您准备编写自己的控件,否则看起来您只是将属性传递给您在那里创建的自定义工具箱控件。
您每次要添加自定义控件时都必须复制它。只需创建一个具有所有正确属性的 sub 并调用它。不是您想要的,但它会完成工作。