![]() |
Add Button at Run-time in Code
I am trying to add a button to a Form in code. When I run the code below the
form shows without a button on it. Why is this? Dim NewBttn As MSForms.CommandButton Set NewBttn = UserForm1.Controls.Add("forms.CommandButton.1") NewBttn.Top = FirstRowSquareTop * Counter NewBttn.Left = FirstRowSquareLeft * Counter NewBttn.Width = FirstRowWidth * Counter NewBttn.Visible = True 'Set NewBttn = Nothing UserForm1.Show End Sub |
Add Button at Run-time in Code
Sorry this does work, my width was set incorrectly.
EM "ExcelMonkey" wrote: I am trying to add a button to a Form in code. When I run the code below the form shows without a button on it. Why is this? Dim NewBttn As MSForms.CommandButton Set NewBttn = UserForm1.Controls.Add("forms.CommandButton.1") NewBttn.Top = FirstRowSquareTop * Counter NewBttn.Left = FirstRowSquareLeft * Counter NewBttn.Width = FirstRowWidth * Counter NewBttn.Visible = True 'Set NewBttn = Nothing UserForm1.Show End Sub |
All times are GMT +1. The time now is 05:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com