liushengk 发表于 2006-9-13 11:45:00

[VBA][请教]如何用代码创建窗体,并在窗体中添加按钮等控件?

<P>请问如何用代码创建窗体,并在窗体中添加按钮等控件??</P>

lion107 发表于 2006-9-21 10:49:00

<P>我也再找啊</P>
<P>希望高手赐教</P>

zdfwyh 发表于 2006-9-28 14:04:00

有难度

liushengk 发表于 2006-10-20 22:21:00

<P>或者怎样在已有的窗体中 用代码创建控件 ?有什么方法吗,各位?</P>

流星蔡园 发表于 2006-10-21 08:37:00

<P>VBA帮助里就有例子:</P>
<P>Dim Mycmd As Control<BR>Private Sub CommandButton1_Click()</P>
<P>&nbsp;&nbsp;&nbsp; Set Mycmd = Controls.Add("Forms.CommandButton.1", "CommandButton3", Visible)<BR>&nbsp;&nbsp;&nbsp; Mycmd.Left = 18<BR>&nbsp;&nbsp;&nbsp; Mycmd.top = 150<BR>&nbsp;&nbsp;&nbsp; Mycmd.Width = 175<BR>&nbsp;&nbsp;&nbsp; Mycmd.Height = 20<BR>&nbsp;&nbsp;&nbsp; Mycmd.Caption = "非常有趣。" &amp; Mycmd.Name<BR>&nbsp;&nbsp;&nbsp; <BR>End Sub</P>
<P>Private Sub UserForm_AddControl(ByVal Control As MSForms.Control)<BR>&nbsp;&nbsp;&nbsp; Label1.Caption = "控件已被添加。"<BR>End Sub</P>
页: [1]
查看完整版本: [VBA][请教]如何用代码创建窗体,并在窗体中添加按钮等控件?