1

The vba macro was developed on 32 bit system, but it is not functioning correctly in 64 bit. It is not importing any file.

Declare PtrSafe Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
    Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean

Declare PtrSafe Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
    Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare PtrSafe Function CommDlgExtendedError Lib "comdlg32.dll" () As Long

Function GetOpenFile(Optional varDirectory As Variant, _
    Optional varTitleForDialog As Variant) As Variant
' Here's an example that gets an Access database name.
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
' Specify that the chosen file must already exist,
' don't change directories when you're done
' Also, don't bother displaying
' the read-only box. It'll only confuse people.
    lngFlags = ahtOFN_FILEMUSTEXIST Or _
                ahtOFN_HIDEREADONLY Or ahtOFN_NOCHANGEDIR
    If IsMissing(varDirectory) Then
        varDirectory = ""
    End If
    If IsMissing(varTitleForDialog) Then
        varTitleForDialog = ""
    End If

    ' Define the filter string and allocate space in the "c"
    ' string Duplicate this line with changes as necessary for
    ' more file templates.
    strFilter = ahtAddFilterItem(strFilter, _
                "Access (*.mdb)", "*.MDB;*.MDA")
    ' Now actually call to get the file name.
    varFileName = ahtCommonFileOpenSave( _
                    OpenFile:=True, _
                    InitialDir:=varDirectory, _
                    Filter:=strFilter, _
                    Flags:=lngFlags, _
                    DialogTitle:=varTitleForDialog)
    If Not IsNull(varFileName) Then
        varFileName = TrimNull(varFileName)
    End If
    GetOpenFile = varFileName
End Function
QHarr
  • 83,427
  • 12
  • 54
  • 101
Rahul
  • 11
  • 1
  • 2
  • https://stackoverflow.com/questions/5724396/excel-64-bit-and-comdlg32-dll-custom-colours – Salek Apr 06 '18 at 15:06
  • You might want to replace this whole function with [this much, MUCH simpler one](https://stackoverflow.com/a/1101541/1188513) – Mathieu Guindon Apr 06 '18 at 15:13
  • Possible duplicate of [Excel 64-bit and comdlg32.dll custom colours](https://stackoverflow.com/questions/5724396/excel-64-bit-and-comdlg32-dll-custom-colours) – QHarr Apr 06 '18 at 15:13

0 Answers0