Change properties of a multipage

G

Gerhard Ganser

I am working with Excel 2007
I have a form (frmMenu) with a multipage (Multipage1)containing 4 pages
(pg1, pg2, pg3, pg4).

I would like to change the visible property of page 4 (pg4) from true to
false using VBA code. I don't seem to be able to find the code needed
to select pg4 to change the properties of this page.

Can you help?



*** Sent via Developersdex http://www.developersdex.com ***
 
P

Peter T

Click the form to toggle visibility of page-4

Private Sub UserForm_Click()
With Me.MultiPage1.Pages(3)
.Visible = Not .Visible
End With
End Sub

Multipage pages are indexed from zero, so MultiPage1.Pages(3) refers to the
4th page

Regards,
Peter T
 
R

RyanH

I'm not sure where you would want this code. Maybe you could insert in under
an Event or insert it into some of you current code but this line will help.

MultiPage1.Pages(3).Visible = True

"MultiPage1" is the name of multipage. So if you have a different name you
will have to change it. The Page Index in a MultiPage starts at 0 by
default. For example, Pages(0) = pg1, Pages(1) = pg2, etc.

Hope this helps!
 
D

Dave Peterson

And you can use the name of the page if you want:

Me.MultiPage1.Pages("pg4").Visible = False
 
O

Oscar

Thanks Peter

The code you sent works fine when I click the user form. I like the
toggle idea.

I would however like to activate the code from a command button that is
on one of the multipages. I have used the code

frmMenu.Multipage1.Pages(3).visible =false

or by modifying your code as follows

With frmMenu.Multipage1.Pages(3)
.visible = not.visible

For some reason it does not seem to identify the page to change the
visible property.

Any thoughts
Thanks again for your help so far!

*** Sent via Developersdex http://www.developersdex.com ***
 
P

Peter T

I ran similarly from a button on a multipage and it worked absolutely fine.
Even if the button is on the page-4 it can at least make itself not visible.

Try this, in your commandbutton's click event

Private Sub CommandButton1_Click()
With Me.MultiPage1.Pages(3)
.Visible = Not .Visible
Me.Caption = UserForm1.MultiPage1.Pages(3).Visible
Me.Caption = .Name & " visible=" & .Visible
End With
End Sub

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

Similar Threads


Top