Josh Hazel
06-17-2010, 10:38 PM
If I have textbox1 on a userform, and want to move it into frame1 on the uerform, how do I do this with vba code? I thought it might be as simple as textbox.left = frame1.left, but apparently not.
ExcelVBA Move Control into a FrameJosh Hazel 06-17-2010, 10:38 PM If I have textbox1 on a userform, and want to move it into frame1 on the uerform, how do I do this with vba code? I thought it might be as simple as textbox.left = frame1.left, but apparently not. CaBieberach 07-13-2010, 09:17 AM Hi Josh, Check this site; it might help you further. http://stackoverflow.com/questions/563972/adding-controls-to-a-frame-in-an-excel-userform-with-vba Josh Hazel 07-21-2010, 08:11 PM That will work good for adding a new control, how can I modify it to work for an existing control? Private WithEvents Cmd As MSForms.CommandButton Private WithEvents Lbl As MSForms.Label Private Sub UserForm_Initialize() Set Lbl = Frame1.Controls.Add("Forms.Label.1", "lbl1") Lbl.Caption = "Foo" Set Cmd = Frame1.Controls.Add("Forms.CommandButton.1", "cmd1") End Sub Private Sub Cmd_Click() Cmd.Top = Cmd.Top + 5 End Sub Private Sub Lbl_Click() Lbl.Top = Lbl.Top + 5 End Sub Colin Legg 07-22-2010, 02:01 AM how can I modify it to work for an existing control? At runtime, AFAIK you can't. You would effectively be trying to change the Parent of the control. Either add a new control at runtime, or add a control at design time and make it visible at runtime. Josh Hazel 08-02-2010, 07:48 PM Okay thanks, what I got from that - you cant change the parent of a control, so I learned something new. Thinks it about time to learn another coding language... I have a long way yet to master VBA |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum