Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-31-2016, 05:21 PM
dan88 dan88 is offline Programatically Generate Add Buttons to UserForm Canvas Windows 10 Programatically Generate Add Buttons to UserForm Canvas Office 2016
Novice
Programatically Generate Add Buttons to UserForm Canvas
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default Programatically Generate Add Buttons to UserForm Canvas

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
I have researched on google and nothing remotely to do with this comes up. I have seen ideas to generate temporary on the fly userforms , but I want these buttons to be added to the actual user form canvas.

Is this possible at all?

Really struggling with these buttons and form components.

thank you for any tips

dan
Reply With Quote
Reply



Similar Threads
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
Programatically Generate Add Buttons to UserForm Canvas UserForm textbox exit event activated with navigation buttons...why? help? 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
Programatically Generate Add Buttons to UserForm Canvas Copy a picture canvas: layout is changed odon2007 Drawing and Graphics 1 04-29-2012 03:14 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft