我有一个用户窗体在打开工作簿时打开。 Excel也是隐藏的,这样用户窗体就会显示给用户。
Private Sub Workbook_Open() Application.Visible = False UserForm1.Show vbModeless End Sub但是,这也隐藏了Excel任务栏上的图标,因此当用户单击远离用户窗体时,除非使用alt +选项卡或关闭/最小化用户窗体前面的其他窗口,否则无法返回该窗体。 我不希望用户这样做,有些甚至可能会尝试再次打开表单(假定它已关闭),导致重新打开的提示和错误,我也不想这样做。
实质上,我需要在用户窗体的任务栏上有一个图标。
一旦用户窗体关闭,我就会关闭Excel
Unload UserForm1 Application.Quit我在互联网上发现的这个问题的例子并没有完全达到我想要做的。 更改窗体以最小化并以模态方式打开以将图标保留在任务栏中,而不让用户编辑工作表
Application.WindowState = xlMinimized UserForm1.Show (1)但是,这有两个问题.....第一 - 用户表单不成为焦点,第二 - 用户可以点击任务栏图标,表单现在可以在用户窗体后面看到,这不是我所要的能够做到。
I have a userform that opens upon the opening of the workbook. Excel is also hidden so that the userform is all that is shown to the user.
Private Sub Workbook_Open() Application.Visible = False UserForm1.Show vbModeless End SubHowever, this also hides the icon for Excel on the taskbar, so when a user clicks away from the userform they cannot get back into it unless using alt+tab or closes/minimises other windows that are in front of the userform. I do not want the users to do this and some may even try to open the form again (Presuming It is closed), causing re-open prompts and errors that I do not want either.
Essentially, I need an icon on the taskbar for the userform.
Once the userform is closed I have it so that Excel closes
Unload UserForm1 Application.QuitExamples I have found on the internet for this problem don't quite achieve what I am trying to do. Changing the form to minimise and open as modal works to keep the icon in the taskbar and not let the user edit the worksheet
Application.WindowState = xlMinimized UserForm1.Show (1)But this has 2 problems..... 1st - the userform doesn't become the focus, 2nd - the user can click on the taskbar icon and the sheet is now visible behind the userform, which is not what I what them to be able to do.
最满意答案
而不是隐藏应用程序最小化工作簿:
ThisWorkbook.Windows(1).WindowState = xlMinimizedThe answer posted by Gareth on this question:
Excel Useform: How to hide application but have icon in the taskbar
Worked to give me a taskbar icon and was a simple copy and paste.
Thanks all for the help.
更多推荐
发布评论