The code in this project must be updated for use on 64-bit systems

不想你离开。 提交于 2020-06-23 04:26:37

问题


We have been using MS Access database (Office 2007, 32bit) in Windows 7 for a long time but recently we switched into Office 2016, 64 bit.

Now every form is displaying the following message and it's really irritating:

this message

Moreover, the Access window is not getting minimized. I'm not an expert in VBA and don't know what to do. I'm pasting the codes. Please don't suggest any article or documentation provided by Microsoft. I have tried to understand those a lot and failed.

The code being used is:

Option Compare Database
Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

And:

Private Sub Form_Load()
    Application.RunCommand (acCmdAppRestore)
    SetWindowPos Application.hWndAccessApp, 0, 0, 0, 0, 0, 0
    Application.DoCmd.MoveSize 0, 0
End Sub

Previously (in 32-bit office) the Access window used to be hidden on form load but now in 64-bit it's wide open. Please help me to hide the MS Access window in 64-bit version.


回答1:


Upgrading companies software without extensive test is amateurish!

But if that error message is the only problem you are lucky. You need to convert the api arguments declaration to x64, what usually means change allLongdeclarations of handles and pointers to LongPtrand add PtrSafe after Declare.

With the conditional compiler (#If VBA7 Then) Office 2010 and later use the first part, as they support VBA7 (LongPtr), Office 2007 and earlier use the else part with the old declaration.

#If VBA7 Then
    Private Declare PtrSafe Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As LongPtr, ByVal hWndInsertAfter As LongPtr, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
#Else
    Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
#End If

This can be found at Declaring API Functions In 64 Bit Office. Seems like you do not use x86 ActiveX controls or ODBC connections, because they cause trouble too.

You should read the Compatibility Inspector user's guide to get prepared for more trouble;)




回答2:


I agree with ComputerVersteher for the first part, so I'll address the second part of your question. You can make the form invisible by doing this:

Private Sub Form_Load()
    'this turns the forms timer event on every 1 milisecond
    Me.TimerInterval = 1
End Sub

Private Sub Form_Timer()
    Me.Visible = False
    'this turns the timer event off so you don't waste CPU power
    Me.TimerInterval = 0
End Sub


来源:https://stackoverflow.com/questions/56619872/the-code-in-this-project-must-be-updated-for-use-on-64-bit-systems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!