Multipage - If .Page(#).enabled Then

E

Eddie_SP

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?
 
J

Jacob Skaria

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
 
L

Libby

Hi Eddie,

Try this

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

Eddie_SP

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 !
 
L

Libby

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
 

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