vba 从后台和任务栏隐藏 MS Access
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12822326/
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
Hiding MS Access from background and taskbar
提问by dan
I am looking forward to hide the Access background of my project when it's running to give it a more professional look and make it running like a standalone application. I am using Access 2003 and a form is already opening when the project is loaded. I would like to add some code in the Private Sub Form_Open(Cancel As Integer)
of that form to hide the Access background.
我期待在我的项目运行时隐藏它的 Access 背景,以使其具有更专业的外观并使其像独立应用程序一样运行。我正在使用 Access 2003,并且在加载项目时已经打开了一个表单。我想在该Private Sub Form_Open(Cancel As Integer)
表单中添加一些代码来隐藏 Access 背景。
回答by dan
The following will work on older versions of Access (tested on Access 2003):
以下内容适用于旧版本的 Access(在 Access 2003 上测试):
Option Compare Database
Option Explicit
Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Function fSetAccessWindow(nCmdShow As Long)
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
fSetAccessWindow = (loX <> 0)
End Function
Just call fSetAccessWindow(0)
to hide and fSetAccessWindow(1)
to show. Alternatively, use fSetAccessWindow(2)
and fSetAccessWindow(3)
to show minimized/maximized. You can use the Global Const
too. Be careful: Access will be hidden from the taskbar.
只需调用fSetAccessWindow(0)
隐藏和fSetAccessWindow(1)
显示。或者,使用fSetAccessWindow(2)
和fSetAccessWindow(3)
显示最小化/最大化。你也可以使用Global Const
。小心:访问将从任务栏中隐藏。
If it doesn't work with Access 2010, here is another code that could work: http://www.tek-tips.com/faqs.cfm?fid=2562
如果它不适用于 Access 2010,这里是另一个可以工作的代码:http: //www.tek-tips.com/faqs.cfm?fid=2562
The forms must be modalor it won't work. If for some reason you messed up and Access is still running in background but not showing in the taskbar or the task-manager, double click on any Access project again (nothing will happen because Access is still running) and then press ALT+TAB to reach the Access icon (it should magically show up). Nothing happens again because it's hidden, but it's now possible to close it with ALT+F4 if it still has the focus, thus preventing you from rebooting your computer...
表单必须是模态的,否则将不起作用。如果由于某种原因你搞砸了并且 Access 仍在后台运行但没有显示在任务栏或任务管理器中,请再次双击任何 Access 项目(不会发生任何事情,因为 Access 仍在运行),然后按 ALT+TAB到达访问图标(它应该神奇地出现)。什么也没有发生,因为它是隐藏的,但是如果它仍然具有焦点,现在可以使用 ALT+F4 关闭它,从而防止您重新启动计算机......
回答by webzy
In Ms Access 2003 a simple way seem to make the form 1. pop up 2. border style none 3. On form load event run maximise command
在 Ms Access 2003 中,似乎有一种简单的方法可以使表单 1. 弹出 2. 边框样式无 3. 在表单加载事件上运行最大化命令
Private Sub Form_Load()
DoCmd.Maximize
End Sub