0

我想永久隐藏访问窗口。我有一个自动 exe 宏,它最初会隐藏窗口,但是如果用户在任务栏上单击我的数据库图标,如果出现在我的表单后面,那就太烦人了。我想知道是否有办法让它保持低调,而不必到处复制隐藏窗口宏

4

1 回答 1

1

以下内容适用于旧版本的访问(来源:http ://www.vbaexpress.com/kb/getarticle.php?kb_id=74 ):

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 

只需调用fSetAccessWindow(0)隐藏和fSetAccessWindow(1)显示。或者,您可以使用fSetAccessWindow(2)andfSetAccessWindow(3)来显示最小化/最大化。该应用程序也将从任务栏中隐藏,以防止用户单击它。

如果它不适用于 Access 2010,您也可以试试这个:http ://www.tek-tips.com/faqs.cfm?fid=2562

于 2012-10-10T14:39:13.773 回答