vba 如何隐藏选项卡并使它们在选择特定选项按钮后出现?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24677985/
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
How to hide tabs and make them appear after a specific optionbutton is selected?
提问by Ali Lumsden
I posted earlier, but since have made some good progress and figured some stuff out by myself!
我之前发布过,但自从取得了一些不错的进展并自己想出了一些东西!
I have nearly finished my project, but need to make the last real bit of code, then just some general tidying up.
我几乎完成了我的项目,但需要制作最后的真正代码,然后只是一些一般的整理。
What I want to do
我想做的事
- I currently have two page in a MultiPage userform - one called 'main' and one called 'extra
- I want Main to always be shown to the user
- I want Extra to be hidden and for this page to be shown automatically under a specific condition
- 我目前在 MultiPage 用户表单中有两个页面 - 一个称为“main”,一个称为“extra”
- 我希望 Main 始终显示给用户
- 我希望隐藏额外内容,并在特定条件下自动显示此页面
I have a question on my userform (using Option Buttons):
我有一个关于我的用户表单的问题(使用选项按钮):
"Did the customer ask about an extra product today?"
“客户今天是否询问了额外的产品?”
If the answer to this question is no
如果这个问题的答案是否定的
When the user hits the command button (after filling out the rest of the form), do nothing special - just return all the values to the worksheet.
当用户点击命令按钮时(在填写完表单的其余部分之后),不要做任何特别的事情 - 只需将所有值返回到工作表。
If the answer is yes
如果答案是肯定的
When the user hits the command button, I want them to be taken to the 'extra' page. They will fill out some additional check-boxes, then hit another command box, which will return the info from both the 'main' and 'extra' sheets together, into the same row of the worksheet.
当用户点击命令按钮时,我希望他们被带到“额外”页面。他们将填写一些额外的复选框,然后点击另一个命令框,这会将“主要”和“额外”工作表中的信息一起返回到工作表的同一行中。
In brief: I want my 'extra' tab to be hidden, only to appear when 'yes' is selected, and for the results all to go back to the worksheet. If you want to see my workbook:
简而言之:我希望我的“额外”选项卡被隐藏,只有在选择“是”时才会出现,并且所有结果都返回到工作表。如果你想看我的工作簿:
https://drive.google.com/file/d/0B2F...it?usp=sharing
https://drive.google.com/file/d/0B2F...it?usp=sharing
Can this be done? Thank you for your help :D
这能做到吗?谢谢你的帮助:D
How I have hidden my Pages
我如何隐藏我的页面
- I have changed the properties of the multipage to : "Style: fmTabStyleNone."
- 我已将多页的属性更改为:“样式:fmTabStyleNone”。
Now I just need the code to make my command button send the user to the next page, if required.
现在,如果需要,我只需要代码来让我的命令按钮将用户发送到下一页。
This isn't working for me. Any ideas??
这对我不起作用。有任何想法吗??
If ProductEnquiryYes.Value = True Then
With MultiPage1
If .SelectedItem.Index < .Pages.Count - 1 Then
.Value = .SelectedItem.Index + 1
End If
End With
End If
回答by user3514930
You can use the propriety Visible.
If the Tabs name is **TabStrip1:**
您可以使用 Visible 属性。
如果选项卡名称是 **TabStrip1:**
TabStrip1.Tabs(1).Visible = False
hide the second Tab. The Index Start From 0 to n-1 tabs.
When you Show, you can also active the tabs with:
隐藏第二个选项卡。索引从 0 开始到 n-1 选项卡。
当您显示时,您还可以通过以下方式激活选项卡:
TabStrip1.Tabs(1).Visible = True
TabStrip1.Value = 1
With Multipages:
使用多页:
MultiPage1.Pages(1).Visible = True
MultiPage1.Value = 1