Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visible Shapes in a frame? Pas Excel Discussion (Misc queries) 4 April 21st 10 08:13 AM
How to attach legend frame to chart frame? holg3r Charts and Charting in Excel 2 July 7th 05 11:41 PM
OptionButton nrage21[_69_] Excel Programming 1 September 29th 04 02:14 AM
OptionButton nrage21[_70_] Excel Programming 0 September 29th 04 12:23 AM
Better Way to Use OptionButton [email protected] Excel Programming 0 September 1st 04 07:18 PM


All times are GMT +1. The time now is 09:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"