ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multipage - If .Page(#).enabled Then (https://www.excelbanter.com/excel-programming/432720-multipage-if-page-enabled-then.html)

Eddie_SP[_2_]

Multipage - If .Page(#).enabled Then
 
Hi !

I have a multipage with 5 pages.
I want that: only when I select the page #4 ".page(3)" the routine is
activated.

It's something like:


If Me.MultiPage1.Pages(3).Enabled = True Then
Do the command...


But it doesn't work, cause if I click on page 2, whatever, it starts the
command anyway.

I think that my mistake is in the syntax...

Someone help me?

Jacob Skaria

Multipage - If .Page(#).enabled Then
 
Use the Change event...

Private Sub MultiPage1_Change()
If MultiPage1.SelectedItem.Index = 2 Then

End If
End Sub

OR
If MultiPage1.SelectedItem.Caption = "Page2" Then

End If

If this post helps click Yes
---------------
Jacob Skaria


"Eddie_SP" wrote:

Hi !

I have a multipage with 5 pages.
I want that: only when I select the page #4 ".page(3)" the routine is
activated.

It's something like:


If Me.MultiPage1.Pages(3).Enabled = True Then
Do the command...


But it doesn't work, cause if I click on page 2, whatever, it starts the
command anyway.

I think that my mistake is in the syntax...

Someone help me?


Libby

Multipage - If .Page(#).enabled Then
 
Hi Eddie,

Try this

If Me.MultiPage1.Value = 3 Then
MsgBox "Hola" 'or whatever code you have
End If


"Eddie_SP" wrote:

Hi !

I have a multipage with 5 pages.
I want that: only when I select the page #4 ".page(3)" the routine is
activated.

It's something like:


If Me.MultiPage1.Pages(3).Enabled = True Then
Do the command...


But it doesn't work, cause if I click on page 2, whatever, it starts the
command anyway.

I think that my mistake is in the syntax...

Someone help me?


Eddie_SP[_2_]

Multipage - If .Page(#).enabled Then
 
Jacob and Libby =)

Both worked perfectly !!!

Thank yoooou !!! \o/



"Jacob Skaria" wrote:

Use the Change event...

Private Sub MultiPage1_Change()
If MultiPage1.SelectedItem.Index = 2 Then

End If
End Sub

OR
If MultiPage1.SelectedItem.Caption = "Page2" Then

End If

If this post helps click Yes
---------------
Jacob Skaria


"Eddie_SP" wrote:

Hi !

I have a multipage with 5 pages.
I want that: only when I select the page #4 ".page(3)" the routine is
activated.

It's something like:


If Me.MultiPage1.Pages(3).Enabled = True Then
Do the command...


But it doesn't work, cause if I click on page 2, whatever, it starts the
command anyway.

I think that my mistake is in the syntax...

Someone help me?


Eddie_SP[_2_]

Multipage - If .Page(#).enabled Then
 
Now another thing...


When I select this page, the command is to open another file in a server here.
How could I close this file if someone change the page?

Something like:

If Me.MultiPage1.Value < 3 Then
ActiveWorkbook.Close False
End If

Thank you !

Libby

Multipage - If .Page(#).enabled Then
 
Hi Eddie,

Something like this perhaps

Private Sub MultiPage1_Change()
Dim myPath As String
Dim myFname As String
myPath = "C:\folder\"
myFname = "Newbie.xls"
Select Case Me.MultiPage1.Value
Case 3
Workbooks.Open (myPath & myFname)
Case Else
On Error Resume Next
Workbooks(myFname).Close savechanges:=false
On Error GoTo 0
' or you could loop through each open workbook
End Select
End Sub


"Eddie_SP" wrote:

Now another thing...


When I select this page, the command is to open another file in a server here.
How could I close this file if someone change the page?

Something like:

If Me.MultiPage1.Value < 3 Then
ActiveWorkbook.Close False
End If

Thank you !



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

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