Enable Property of Multipage Control Pages = CheckBox.Value

R

RyanH

How can I enable all Pages of a Multipage Control it a checkbox = True, and
disable pages it the checkbox = False?

Sub EnablePages ()

Dim myPages as Collection
Dim ctrl as Control

'all pages in multipage paint section
Set myPages = New Collection
With myPages
.Add pgColor1
.Add pgColor2
.Add pgColor3
.Add pgColor4
.Add pgColor5
.Add pgColor6
End With

For Each ctrl In myPages
ctrl.Enabled = chkPaint.Value
Next ctrl

End Sub
 
J

Jon Peltier

Put this into the Initialize event of the userform to set up the pages you
want:

Private Sub UserForm_Initialize()
Dim pg As Page
With Me.MultiPage1
.Pages.Remove "Page1"
.Pages.Remove "Page2"
.Pages.Add "New Page 1"
.Pages.Add "New Page 2"
.Pages.Add "New Page 3"
.Pages.Add "New Page 4"
.Pages.Add "New Page 5"
For Each pg In .Pages
pg.Enabled = Me.CheckBox1.Value
Next
End With
End Sub

Then use the click event of the check box to change the pages' status when
the checkbox changes:

Private Sub CheckBox1_Click()
Dim pg As Page
For Each pg In Me.MultiPage1.Pages
pg.Enabled = Me.CheckBox1.Value
Next
End Sub

- Jon
 
R

RyanH

Thats what I needed!

Thanks

Jon Peltier said:
Put this into the Initialize event of the userform to set up the pages you
want:

Private Sub UserForm_Initialize()
Dim pg As Page
With Me.MultiPage1
.Pages.Remove "Page1"
.Pages.Remove "Page2"
.Pages.Add "New Page 1"
.Pages.Add "New Page 2"
.Pages.Add "New Page 3"
.Pages.Add "New Page 4"
.Pages.Add "New Page 5"
For Each pg In .Pages
pg.Enabled = Me.CheckBox1.Value
Next
End With
End Sub

Then use the click event of the check box to change the pages' status when
the checkbox changes:

Private Sub CheckBox1_Click()
Dim pg As Page
For Each pg In Me.MultiPage1.Pages
pg.Enabled = Me.CheckBox1.Value
Next
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______
 

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