简体   繁体   中英

move to next page on userform multipage excel VBA

i have 5 pages in multipage userform.

if the next button enabled, which it can be clicked by user then it should move to next hidden page, i always got an error "Object Required" it drives me crazy.

Private Sub btnGenerate_Click()
iPageNo = MultiPage1.Value + 1
MultiPage1.Pages(iPageNo).Visible = True
MultiPage1.Value = iPageNo
End Sub

that code seems doesnt work for me, any help would be appreciate.

Thanks

Which line is causing the error when you step thru?

Ensure there are enough existing pages. Also, has the name of the MultiPage object changed?

This code below tested working (2 Pages in MultiPage1, Page2 set hidden):

Option Explicit

Private Sub CommandButton1_Click()
    Dim iNextPage As Long
    With Me.MultiPage1
        iNextPage = .Value + 1
        If iNextPage < .Pages.Count Then
            .Pages(iNextPage).Visible = True
            .Value = iNextPage
        End If
    End With
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM