Adding an Object to a MultiPage

G

Guest

I can add an optionbutton to a UserForm via the code below. What I am trying
to do, however, is to add the option button to "Page1" of "MultiPage1" of
"UserForm1". I can't seem to get this to work. Any Ideas?

Thanks

Sub AddOptionButton()
Dim MyForm
Dim NewOptBtn As Msforms.OptionButton

Set MyForm = ThisWorkbook.VBProject.VBComponents("UserForm1")
Set NewOptBtn = MyForm.Designer.Controls.Add("forms.OptionButton.1")
End Sub
 
P

Peter T

Set NewOptBtn = _
MyForm.Designer.Controls("MultiPage1").Pages(0).Add("forms.OptionButton.1")

Assuming "Page1" is the first page its index is 0

Regards,
Peter T
 
G

Guest

Thank You Peter

Peter T said:
Set NewOptBtn = _
MyForm.Designer.Controls("MultiPage1").Pages(0).Add("forms.OptionButton.1")

Assuming "Page1" is the first page its index is 0

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top