2011-03-09 87 views
0

fAccessWindow(「隱藏」,假,假)隱藏實際的訪問窗函數給出編譯錯誤編號7960fAccessWindow(「隱藏」,假,假)給出編譯錯誤

我沒有空間已經試過「fAccessWindow(」隱藏「,假,假)」但沒有區別。我也有一個模塊,下面的代碼也可以找到here。我正在使用最低級別的宏安全性的Access 2010。另外我的操作系統是x64。

Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long 
Dim dwReturn As Long 

Const SW_HIDE = 0 
Const SW_SHOWNORMAL = 1 
Const SW_SHOWMINIMIZED = 2 
Const SW_SHOWMAXIMIZED = 3 

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ 
    ByVal nCmdShow As Long) As Long 

Public Function fAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean 
If Procedure = "Hide" Then 
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE) 
End If 
If Procedure = "Show" Then 
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED) 
End If 
If Procedure = "Minimize" Then 
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED) 
End If 
If SwitchStatus = True Then 
    If IsWindowVisible(hWndAccessApp) = 1 Then 
     dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE) 
    Else 
     dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED) 
    End If 
End If 
If StatusCheck = True Then 
    If IsWindowVisible(hWndAccessApp) = 0 Then 
     fAccessWindow = False 
    End If 
    If IsWindowVisible(hWndAccessApp) = 1 Then 
     fAccessWindow = True 
    End If 
End If 
End Function 
+0

首先,你不表明你說的是導致編譯錯誤代碼(你」重新顯示被調用的代碼,但不是調用它的代碼正在生成錯誤);其次,你沒有顯示你得到的實際錯誤信息。請提供這些詳細信息以便人們能夠幫助您。 – 2011-03-09 22:40:26

+0

「編譯此函數時出現錯誤」,則宏名稱,操作名稱「RunCode」,參數「fAccessWindow(」Hide「,False,False)」錯誤編號「7960」 – 2011-03-09 22:43:33

回答

2

您需要參考this article from MS on 64-bit VBA和使用不僅僅是PTRSAFE,也是新龍龍的數據類型,你需要使用條件編譯:

#if Win64 then 
     Private Declare PtrSafe Function IsWindowVisible Lib "user32" (ByVal hwnd As LongLong) As LongLong 
    #else 
     Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long 
    #end if 

我不是編程64位訪問,所以沒有與此工作。我不清楚Win64和VBA7編譯常量之間的相互作用是什麼,引用的文章不完全清楚。這不是我清楚,如果你應該這樣做:

#If Win64 And VBA7 Then 
     ... 
    #Else 
     ... 
    #End If 

,或者如果它應該是:

#If Win64 Then 
     #If VBA7 Then 
     ... 
     #Else 
     ... 
     #End If 
    #Else 
     #If VBA7 Then 
     ... 
     #Else 
     ... 
     #End If 
    #End If 
0

我添加PTRSAFE選項下面的功能,並開始在x64的工作,但現在它是給在x86機器上同樣的錯誤。

Private Declare PtrSafe Function IsWindowVisible Lib "user32"_ 
    (ByVal hwnd As Long) As Long 

Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ 
    ByVal nCmdShow As Long) As Long