Migration 64 bits - Openbox ne fonctionne pas
Salut à tous,
Je dois faire tourner mon application Access sous Access 64 bits.
J'ai donc ajouté a mes appels api le PtrSafe et sur quelques variable le LongPtr recommandé sur toutes pages sur le sujet.
Mon application démarre bien, mais je n'arrive pas à ouvrir une open box pour choisir un fichier Excel.
Pourriez-vous m'aider?, je sèche !!!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
Type tagOPENFILENAME
lStructSize As Long
hwndOwner As LongPtr
hInstance As LongPtr
strFilter As String
strCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
strFile As String
nMaxFile As Long
strFileTitle As String
nMaxFileTitle As Long
strInitialDir As String
strTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
strDefExt As String
lCustData As LongPtr
lpfnHook As LongPtr
lpTemplateName As String
pvReserved As LongPtr
dwReserved As Long
FlagEx As Long
End Type
Declare PtrSafe Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
Function ahtCommonFileOpenSave( _
Optional ByRef Flags As Variant, _
Optional ByVal InitialDir As Variant, _
Optional ByVal Filter As Variant, _
Optional ByVal FilterIndex As Variant, _
Optional ByVal DefaultExt As Variant, _
Optional ByVal FileName As Variant, _
Optional ByVal DialogTitle As Variant, _
Optional ByVal hwnd As LongPtr, _
Optional ByVal OpenFile As Variant) As Variant
With OFN
.lStructSize = Len(OFN)
.hwndOwner = hwnd
.strFilter = Filter
.nFilterIndex = FilterIndex
.strFile = strFileName
.nMaxFile = Len(strFileName)
.strFileTitle = strFileTitle
.nMaxFileTitle = Len(strFileTitle)
.strTitle = DialogTitle
.Flags = Flags
.strDefExt = DefaultExt
.strInitialDir = InitialDir
' Didn't think most people would want to deal with
' these options.
.hInstance = 0
'.strCustomFilter = ""
'.nMaxCustFilter = 0
.lpfnHook = 0
'New for NT 4.0
.strCustomFilter = String(255, 0)
.nMaxCustFilter = 255
End With
If OpenFile Then
fResult = aht_apiGetOpenFileName(OFN)
Else
fResult = aht_apiGetSaveFileName(OFN)
End If |
Voici en partie mon code, je ne vois vraiment pas pourquoi rien ne se passe.
Avec le meme code en 32 bit cela fonctionne très bien
Merci à vous
Migration 64 bits - Openbox ne fonctionne pas
Essayez ceci:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Sub FileSelection() 'Requiert reference à Microsoft Office 12.0 Object Library,
'ou Microsoft Office 15.0 Object Library.
Dim fdialog As Office.FileDialog
Dim varFile As Variant
Set fdialog = Application.FileDialog(msoFileDialogFilePicker)
With fdialog
'Eviter les choix multiples.
.AllowMultiSelect = False
.Title = "Choisissez le fichier XL que vous voulez importer"
.Filters.Clear
.Filters.Add "Excel Files", "*.xl*" 'vous pouvez ajouter ou modifier les extensions à volonté !
If .Show = True Then
For Each varFile In .SelectedItems
FileSelectionDialog = varFile
MsgBox "Vous avez choisi : " & varFile
Next
Else
MsgBox "Vous avez annulé la procédure de sélection !."
End If
End With
End Sub |