vba Excel VBA隐藏所有打开的用户表单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18584438/
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
Excel VBA Hide all opened userforms
提问by Chauncey Philpot
I have a medical userform that a clinician will be using. There are several buttons to allow them to navigate to different forms. I'm currently using a Sub that does several checks to see if the forms are visible and if so, don't be. But that's not very friendly for adaptation.
我有一个临床医生将使用的医疗用户表单。有几个按钮可以让他们导航到不同的表单。我目前正在使用 Sub 进行多次检查以查看表单是否可见,如果是,则不可见。但这对适应不是很友好。
Is there a call I can make to hide all currently open visible forms. Or, cycle through all currently opened forms (eg ones in memory) Request one is obviously the lazy one for me. Request two will be sufficient as I can do the code to hide them after that.
是否可以调用以隐藏所有当前打开的可见表单。或者,循环浏览所有当前打开的表单(例如内存中的表单),请求一显然对我来说是懒惰的。请求两个就足够了,因为我可以在此之后执行代码来隐藏它们。
回答by Chauncey Philpot
For potential google searches
对于潜在的谷歌搜索
This was the answer I needed. This will hide any open userforms.
这就是我需要的答案。这将隐藏任何打开的用户表单。
Dim UForm As Object
For Each UForm In VBA.UserForms
If UForm.Visible = True Then
UForm.Hide
End If
Next