![]() |
#1
|
|||
|
|||
![]()
Hi,
I have a userform that I am creating, I wanted to know if I am able to programmatically add buttons to the actual userform. I am having a lot of trouble with these buttons as they assign random numbers to buttons and I am losing count and organization. Lets say I want to add 20 Command buttons on to my userform. I also want to have control over the number that the command button starts at lets say i wanted to generate 20 command buttons , but the number starts at command button 60 so I would have command button 60, command button 61....etc these being added to the userform canvas. the code does not work below Code:
Sub AddButtons() Dim ButtonCount As Integer Dim ctl As Control ' Create the Button objects ButtonCount = 0 With ThisDocument.VBProject.vbComponents("UserForm1").Designer For Each ctl In UserForm1.Controls ButtonCount = ButtonCount + 1 ReDim Preserve Buttons(1 To ButtonCount) Set Buttons(ButtonCount).ButtonGroup = ctl End If End If Next ctl End Sub Is this possible at all? ![]() Really struggling with these buttons and form components. thank you for any tips dan |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Update Userform Captions, TextBoxes, Command buttons From Excel | dan88 | Word VBA | 3 | 05-22-2016 08:59 AM |
Canvas + textbox + group = weird ghost bug? | somads | Word | 0 | 11-25-2015 01:37 AM |
![]() |
orozvik@yahoo.com | Excel Programming | 2 | 05-08-2015 02:50 AM |
VBA Code in a UserForm module to delete a Command Button which opens the userform | Simoninparis | Word VBA | 2 | 09-21-2014 03:50 AM |
![]() |
odon2007 | Drawing and Graphics | 1 | 04-29-2012 03:14 AM |