adding a routine/event to a control during execution  
Author Message
Pierpaolo





PostPosted: Visual Basic for Applications (VBA), adding a routine/event to a control during execution Top

Hi to all,

I'm writing a macro in Excel, and just added a commandbutton to a form during its execution, but i'm not able to assign an execution code/routine to it! i've tryed the help on line and haven't found anything usefull, may you help me

Private Sub UserForm_Initialize()
Dim CButton As Control
Dim X, Y

X=8
Y=16

Set CButton = frmDiametri_e_Spessori.Controls.Add("Forms.CommandButton.1")
CButton.Left = X
CButton.Top = Y
CButton.Caption = "OK"

End sub

Now i want to add some code to the CButton control so that, when clicked, it apply the changes i've done in the form

Thanks

Pierpaolo




Microsoft ISV Community Center Forums2  
 
 
Uwe_Neufeld





PostPosted: Visual Basic for Applications (VBA), adding a routine/event to a control during execution Top

Put your button togheter with the code at design time, setting the visible property to false. At runtime you change the design attributes and finally make the button visible.