amel3011
Messages postés18Date d'inscriptionmercredi 5 novembre 2008StatutMembreDernière intervention14 avril 2009
-
9 nov. 2008 à 16:11
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 2018
-
9 nov. 2008 à 16:32
Bonjour,
je cherche une propriété de CommonDialog qui m'aiderais à spécifier un chemin.
j'utilise le code suivant pour ouvrir une base de donnée et par la même occasion trouver son chemin, mais maintenant je veut spécifié juste le chemin ou un repertoire sans choisir un fichier
With dlgCommonDialog
'À faire définir les indicateurs et attributs
'du contrôle des dialogues communs
.Filter = "Fichiers Bases de données Accesss (*.mdb)|*.mdb"
.DialogTitle = "Veuillez choisir la base de données RD"
.ShowOpen
If Len(.FileName) = 0 Then
Chercher_Chemin = False
Else
chemin_rd = .FileName
End If
End With
Merci
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Private Const BIF_RETURNONLYFSDIRS As Long
= 1&
Private Const MAX_LENGTH As Long = 512&
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Function BrowseDirectory(Optional ByVal lHandle As Long = 0, Optional
ByVal sTitle As String
= vbNullString) As
String
' crée à partir de
l'API-GUID
Dim tBI As BrowseInfo, lRet As Long, sBuffer As String
With tBI
.hWndOwner = lHandle
.lpszTitle = lstrcat(sTitle, vbNullChar)
.ulFlags = BIF_RETURNONLYFSDIRS
End With
lRet = SHBrowseForFolder(tBI)
If lRet Then
sBuffer = String$(MAX_LENGTH, vbNullChar)
Call SHGetPathFromIDList(lRet, sBuffer)
Call CoTaskMemFree(lRet)
sBuffer = LeftB$(sBuffer, InStrB(sBuffer, vbNullChar))
BrowseDirectory = sBuffer
End If
End Function