Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
OptionButton in a Frame not visible
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
OptionButton in a Frame not visible
Try adding the optionbutton to the frame--not the form:
Set uiOptionButton1 = _ uiForm1.Designer.Controls.Add("Forms.OptionButton. 1") Becomes Set uiOptionButton1 = _ uiFrame1.Controls.Add("Forms.OptionButton.1") JoeBen wrote: 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 -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
OptionButton in a Frame not visible
That solved it!
Thanks. "Dave Peterson" wrote: Try adding the optionbutton to the frame--not the form: Set uiOptionButton1 = _ uiForm1.Designer.Controls.Add("Forms.OptionButton. 1") Becomes Set uiOptionButton1 = _ uiFrame1.Controls.Add("Forms.OptionButton.1") JoeBen wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visible Shapes in a frame? | Excel Discussion (Misc queries) | |||
How to attach legend frame to chart frame? | Charts and Charting in Excel | |||
OptionButton | Excel Programming | |||
OptionButton | Excel Programming | |||
Better Way to Use OptionButton | Excel Programming |