简体   繁体   English

将用户表单多页启动到特定页面

[英]Start userform multipage into a specific page

I have a Userform named SheetBox我有一个名为SheetBox 的用户表单

SheetBox contains a 3-page multipage window SheetBox包含一个 3 页的多页窗口

"page1" for selecting sheets to import “page1”用于选择要导入的工作表
"page2" contains a pseudo progress bar “page2”包含一个伪进度条
"page3" for selecting sheets to protect “page3”用于选择要保护的纸张

What I need now is a method to open a specific page upon opening the Userform when a button on a worksheet is clicked我现在需要的是一种在单击工作表上的按钮时打开用户窗体时打开特定页面的方法

ex:前任:
ImportBttn opens page1 of userform ImportBttn打开用户表单的第 1
ProtctBttn opens page3 of userform ProtctBttn打开用户表单的 page3

I'm doing this to reduce the number of userform I needed to create, instead of creating 3 separate userforms.我这样做是为了减少我需要创建的用户表单的数量,而不是创建 3 个单独的用户表单。 This also helps reduce the filesize.这也有助于减少文件大小。

This works too 这也有效

Sub ImportBttn_Click()
Load SheetBox: SheetBox.MultiPage1.Value = 0: SheetBox.Show
End Sub

Sub ProtctBttn_Click()
Load SheetBox: SheetBox.MultiPage1.Value = 2: SheetBox.Show
End Sub

this loads sheetbox first, changes the multipage page and shows it afterwards 这首先加载工作表,更改多页面并在之后显示它

but thanks for the caller method, will be useful when I need to know what button gets pressed 但是感谢调用者方法,当我需要知道什么按钮被按下时会很有用

In the UserForms Initialise Event, use Application.Caller to detect which button on the worksheet was pressed, and then set the multipage 在UserForms Initialise事件中,使用Application.Caller检测工作表上的哪个按钮被按下,然后设置multipage

Private Sub UserForm_Initialize()
Select Case Application.Caller
Case "ImportBttn"
`1st tab
Me.MultiPage1.Value = 0
Case "ProtctBttn"
`3rd tab
Me.MultiPage1.Value = 2
End Select
End Sub

My project using several multiPages.我的项目使用了几个多页面。 Since the user-defined names for the tabs are dynamic, I set the default Tab with ...由于选项卡的用户定义名称是动态的,因此我将默认选项卡设置为 ...

Sub iconDailyEntry_Click()
    Call init_GUI(frmGUI.mulGUI, "pgDaily")
End Sub

Sub init_GUI(mPage As MSForms.MultiPage, pgName As String)
  mPage.Value = mPage(pgName).Index
  mPage.Parent.Show
End Function

Rinse & repeat for each button's click event.冲洗并重复每个按钮的点击事件。 Cheers.干杯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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