vba 仅打开用户窗体而不闪烁 Excel 窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26568264/
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
Opening Userform only without flashing Excel Window
提问by AndroidDev
I know the method as Application.Visible = False
and Application.Screenupdating = False
我知道方法Application.Visible = False
和Application.Screenupdating = False
When opening the file, I want the user to see onlythe userform.
打开文件时,我希望用户只看到用户表单。
The thing is: with these two commands above, Excel appears for 1 second. Is it possible to do it without Excel blinking like this?
问题是:使用上面的这两个命令,Excel 会出现 1 秒钟。有没有可能在没有 Excel 像这样闪烁的情况下做到这一点?
Thanks in advance.
提前致谢。
回答by ZAT
You may try to open the excel file not with excel itself to avoid the splash. Try script to open excel file, then form will open without splash :
您可以尝试不使用 excel 本身打开 excel 文件以避免飞溅。尝试脚本打开 excel 文件,然后表单将打开而不会飞溅:
'save this in a text file, change extension as .vbs
将其保存在文本文件中,将扩展名更改为.vbs
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = false
Set objWorkbook = objExcel.Workbooks.Open("C:\Users\USER\Desktop\yourfile.xlsm")
'this will open excel as invisible, so to close excel you have to insert some button inside userformor something like ThisWorkbook.Close savechanges = False
or Application.Quit
“这将打开Excel作为无形的,所以要关闭Excel你要插入一些按钮内部用户窗体或喜欢的东西ThisWorkbook.Close savechanges = False
或Application.Quit
'and of course assuming that your form is in the workbook_open in your project like
'当然假设您的表单在您的项目中的 workbook_open 中,例如
Private Sub Workbook_Open()
'ActiveWindow.WindowState = xlMinimized
'Application.Visible = False
Application.ScreenUpdating = False
Application.EnableEvents = False
'Application.EnableAnimations = False
UserForm1.Show
End Sub