Programmely written code don't work
The code that is create in runtime is created like this:
Sub AddButtonsCode()
Dim UFvbc As Object 'VBComponent
Dim code As String
Dim n As Long
Set UFvbc = ThisWorkbook.VBProject.VBComponents("UserForm1")
For n = 1 To 10
With UFvbc.CodeModule
code = ""
code = code & "Private Sub OptionButton" & n & "_Click" & vbCr
code = code & "Msgbox ""YES - OptionButton" & n & """" & vbCr
code = code & "End Sub"
.InsertLines .CountOfLines + 1, code
End With
Next
End Sub
"Flemming Dahl" wrote in message
...
Hi,
On a userform certain actions course extra controls AND extra event-code
for
thise controls - however the code looks right........... it will not
work......
A OptionButton is created "OptionButton1" and this code is made one the
userform's code module:
Private Sub OptionButton1_Click()
MsgBox "YES"
End Sub
What do i do to make the new code work ?
Thanks,
Flemming
|