Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am having some trouble inserting objects onto a form and using
automatically inserted code. I start with a blank userform. The segment below addes an optionbuttion and writes some code to handle clicks on it. Notice the commented out "OptionButton1_Click". Of course, it needs to be commented out because otherwise UserForm_Initialize() would not compile because it does not exist at the program's start. The new sub is created ok, but when I click on the resulting option button, nothing happens. Why not????? Private Sub UserForm_Initialize() Dim cntNew As MSForms.Control Set cntNew = UserForm2.Controls.Add("Forms.OptionButton.1") With cntNew .Value = False With Application.VBE.ActiveVBProject.VBComponents("User Form2").CodeModule .InsertLines .CountOfLines + 1, ("Sub " & cntNew.Name & "_Click()") .InsertLines .CountOfLines + 1, ("msgbox ""Here - New Subroutine!!!!!""") ' tag .InsertLines .CountOfLines + 1, ("End Sub") End With MsgBox .Name ' OptionButton1_Click End With Set cntNew = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Automatically generating a city name based on entered zip code | Excel Discussion (Misc queries) | |||
Automatically insert a new row when certain number is entered in c | Excel Discussion (Misc queries) | |||
Dates-Automatically entered in cells | Excel Discussion (Misc queries) | |||
Contents automatically entered into another cell | New Users to Excel | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions |