Selecti Page in Userform by Name not Number

  • Thread starter Thread starter Trefor
  • Start date Start date
T

Trefor

I understand the use of this command:

Menu.MultiPage1.Pages(8).Enabled = True

BUT what I would like to do is not use a page number and use the Pages name
instead, is this possible?

Something like:

Menu.MultiPage1.Pages("Main Menu").Enabled = True
 
I don't think that you can do it that easily, what you can do is run
through all pages and look for the name:

'----------------------------------
Function return_pageNum(PageName As String) As Byte

return_pageNum = 0

For i = 0 To Me.MultiPage1.Pages.Count
Debug.Print Me.MultiPage1.Pages(i).Name
If LCase(Me.MultiPage1.Pages(i).Name) = LCase(PageName) Then
return_pageNum = i
Exit For
End If
Next i

End Function
'----------------------------------

if there is an easier possibility, i'm eager to learn.

cheers carlo
 
The problem is you are trying to use the Caption property to identify the
Page within the collection, not the Page's name. When you click on the tab
for the "Main Menu", look at the Properties window... see the Name, it is
Page8 (or whatever number your page is). Change the name to MainMenu
(notice, because it is a name, you can't have a separating space in it);
now, change "Main Menu" to "MainMenu" in your code statement and it should
work the way you are expecting.

Rick
 
Wait a second...i just tried it and this works for me:

me.multipage1.pages("mypage").enabled = true

what excel are you using?

Carlo
 
Did you rename the page to that Name? Notice the OP has a space in his
"name", which must mean he is trying to reference the page through its
Caption, not its Name.

Rick


Wait a second...i just tried it and this works for me:

me.multipage1.pages("mypage").enabled = true

what excel are you using?

Carlo
 

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

Back
Top