Compile Error

thingssocomplex

Registered User.
Local time
Today, 08:39
Joined
Feb 9, 2009
Messages
178
Hello,

An error appears for the below code and the 'Function' is highlighted when the error is flagged, the error is below, could anybody assist with with how I can resolve?

Code:
Option Compare Database
Option Explicit

Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long

Public CDCaption, CDSearchString, CDInitDir As String

The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements ant then mark them with the PtrSafe attribute
 
first things first, do you have the OPENFILENAME structure declared in your code?
 
I can confirm the it is declared, the VBA Macro works correctly when running on MS Office 32-Bit but fails when running on Office 64-Bit. I think I may have rectified just waiting for an end user to confirm by simplying PtrSafe after 'Declare' if this does resolve the issue I will confirm.
 
I can confirm the it is declared, the VBA Macro works correctly when running on MS Office 32-Bit but fails when running on Office 64-Bit. I think I may have rectified just waiting for an end user to confirm by simplying PtrSafe after 'Declare' if this does resolve the issue I will confirm.

Sounds correct... I didn't see where you specifically said you were working with Office 64, but yes, you'll need PtrSafe for the declaration.

Also note you'll want LongPtr datatype for pointers in the OPENFILENAME structure... (these were previously just Long with 32bit office)

cheers,
 
Sorry for the confusion, I am working on 32-Bit, I however sent the DB to a number of colleagues and a couple of these had 64-Bit versions which generated the error initially raised. Many thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom