移至用户表单多页 excel VBA 上的下一页
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40966306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
move to next page on userform multipage excel VBA
提问by Ibrahim Al Rosid
i have 5 pages in multipage userform.
我在多页用户表单中有 5 页。
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
谢谢
采纳答案by PatricK
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?
确保有足够的现有页面。另外,MultiPage 对象的名称是否已更改?
This code below tested working (2 Pages in MultiPage1, Page2 set hidden):
下面的代码测试了工作(MultiPage1 中的 2 页,Page2 设置为隐藏):
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