G
Guest
Hi,
I am using the attached code to generate a Form, a Frame, and
an OptionButton.
When the Form is shown, the OptionButton is not visible.
I played with other components inside a Frame, and the problem
persisted.
I am running Excel XP on Windows XP.
Thanks, JoeBen
=====
Sub Test()
Dim uiForm1 As Object
Set uiForm1 = ActiveWorkbook.VBProject.VBComponents.Add(3)
With uiForm1
.Properties("Caption") = "uiForm1"
.Properties("Left") = 11
.Properties("Top") = 22
.Properties("Width") = 444
.Properties("Height") = 333
End With
Dim uiFrame1 As MSForms.Frame
Set uiFrame1 = _
uiForm1.Designer.Controls.Add("Forms.Frame.1")
With uiFrame1
.Caption = "uiFrame1"
.Left = 31
.Top = 42
.Width = 404
.Height = 253
End With
Dim uiOptionButton1 As MSForms.OptionButton
Set uiOptionButton1 = _
uiForm1.Designer.Controls.Add("Forms.OptionButton.1")
With uiOptionButton1
.Caption = "uiOptionButton1"
.Left = 51
.Top = 62
.Width = 40
.Height = 30
End With
Dim uisheet1 As Worksheet
Set uisheet1 = Sheets.Add
With uisheet1
.Name = "uisheet2"
End With
Dim uiCommandButton1 As OLEObject
Set uiCommandButton1 = _
ActiveSheet.OLEObjects.Add("Forms.CommandButton.1")
With uiCommandButton1
.Object.Caption = "Show Form"
.Left = 71
.Top = 82
.Width = 60
.Height = 30
End With
Insert_uiCommandButton1_click_sub
End Sub
Sub Insert_uiCommandButton1_click_sub()
Dim sCode As String, sName As String, lNextLine As Long
sCode = "sub CommandButton1_click()" & vbCrLf
sCode = sCode & "UserForm2.Show" & vbCrLf
sCode = sCode & "End Sub" & vbCrLf
sName = ActiveSheet.CodeName
With ActiveWorkbook.VBProject. _
VBComponents(sName).CodeModule
lNextLine = .CountOfLines + 1
.InsertLines lNextLine, sCode
End With
End Sub
I am using the attached code to generate a Form, a Frame, and
an OptionButton.
When the Form is shown, the OptionButton is not visible.
I played with other components inside a Frame, and the problem
persisted.
I am running Excel XP on Windows XP.
Thanks, JoeBen
=====
Sub Test()
Dim uiForm1 As Object
Set uiForm1 = ActiveWorkbook.VBProject.VBComponents.Add(3)
With uiForm1
.Properties("Caption") = "uiForm1"
.Properties("Left") = 11
.Properties("Top") = 22
.Properties("Width") = 444
.Properties("Height") = 333
End With
Dim uiFrame1 As MSForms.Frame
Set uiFrame1 = _
uiForm1.Designer.Controls.Add("Forms.Frame.1")
With uiFrame1
.Caption = "uiFrame1"
.Left = 31
.Top = 42
.Width = 404
.Height = 253
End With
Dim uiOptionButton1 As MSForms.OptionButton
Set uiOptionButton1 = _
uiForm1.Designer.Controls.Add("Forms.OptionButton.1")
With uiOptionButton1
.Caption = "uiOptionButton1"
.Left = 51
.Top = 62
.Width = 40
.Height = 30
End With
Dim uisheet1 As Worksheet
Set uisheet1 = Sheets.Add
With uisheet1
.Name = "uisheet2"
End With
Dim uiCommandButton1 As OLEObject
Set uiCommandButton1 = _
ActiveSheet.OLEObjects.Add("Forms.CommandButton.1")
With uiCommandButton1
.Object.Caption = "Show Form"
.Left = 71
.Top = 82
.Width = 60
.Height = 30
End With
Insert_uiCommandButton1_click_sub
End Sub
Sub Insert_uiCommandButton1_click_sub()
Dim sCode As String, sName As String, lNextLine As Long
sCode = "sub CommandButton1_click()" & vbCrLf
sCode = sCode & "UserForm2.Show" & vbCrLf
sCode = sCode & "End Sub" & vbCrLf
sName = ActiveSheet.CodeName
With ActiveWorkbook.VBProject. _
VBComponents(sName).CodeModule
lNextLine = .CountOfLines + 1
.InsertLines lNextLine, sCode
End With
End Sub