ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecti Page in Userform by Name not Number (https://www.excelbanter.com/excel-programming/403097-selecti-page-userform-name-not-number.html)

Trefor

Selecti Page in Userform by Name not Number
 

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
--
Trefor

carlo

Selecti Page in Userform by Name not Number
 
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

On Dec 21, 10:49*am, Trefor wrote:
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
--
Trefor



Rick Rothstein \(MVP - VB\)

Selecti Page in Userform by Name not Number
 
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


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
--
Trefor



carlo

Selecti Page in Userform by Name not Number
 
Wait a second...i just tried it and this works for me:

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

what excel are you using?

Carlo

On Dec 21, 11:04*am, carlo wrote:
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

On Dec 21, 10:49*am, Trefor wrote:



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
--
Trefor- Hide quoted text -


- Show quoted text -



Rick Rothstein \(MVP - VB\)

Selecti Page in Userform by Name not Number
 
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


"carlo" wrote in message
...
Wait a second...i just tried it and this works for me:

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

what excel are you using?

Carlo

On Dec 21, 11:04 am, carlo wrote:
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

On Dec 21, 10:49 am, Trefor wrote:



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
--
Trefor- Hide quoted text -


- Show quoted text -



Trefor

Selecti Page in Userform by Name not Number
 
Rick,

Spot on thanks. Should have thought about that myself.

--
Trefor


"Rick Rothstein (MVP - VB)" wrote:

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


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
--
Trefor




Trefor

Selecti Page in Userform by Name not Number
 
Carlo,

Thanks for your help, between you and Rick its fixed thanks.
--
Trefor


"carlo" wrote:

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

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

what excel are you using?

Carlo

On Dec 21, 11:04 am, carlo wrote:
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

On Dec 21, 10:49 am, Trefor wrote:



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
--
Trefor- Hide quoted text -


- Show quoted text -





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com