G Guest Dec 4, 2005 #1 Hi, Can anyone tell me how I can add a label to a form at runtime. Regards, Ron.
I Ian Dec 4, 2005 #2 I don't know if you can do this, but you could create a label beforehand with a blank caption then use Label1.Caption = "Test label" at runtime to populate it.
I don't know if you can do this, but you could create a label beforehand with a blank caption then use Label1.Caption = "Test label" at runtime to populate it.
B Bob Phillips Dec 4, 2005 #3 Dim newCtl As msforms.Control Set newCtl = Me.Controls.Add("Forms.Label.1") newCtl.Caption = "New Label" With newCtl .Left = 100 .Top = 50 .Visible = True End With -- HTH RP (remove nothere from the email address if mailing direct)
Dim newCtl As msforms.Control Set newCtl = Me.Controls.Add("Forms.Label.1") newCtl.Caption = "New Label" With newCtl .Left = 100 .Top = 50 .Visible = True End With -- HTH RP (remove nothere from the email address if mailing direct)
T Tom Ogilvy Dec 4, 2005 #4 If by form, you mean a userform: Private Sub UserForm_Initialize() Dim LBL As MSForms.Label Set LBL = Controls.Add("Forms.Label.1", "Lable2", True) LBL.Top = 5 LBL.Left = 5 LBL.Caption = "abcd" End Sub
If by form, you mean a userform: Private Sub UserForm_Initialize() Dim LBL As MSForms.Label Set LBL = Controls.Add("Forms.Label.1", "Lable2", True) LBL.Top = 5 LBL.Left = 5 LBL.Caption = "abcd" End Sub