En poursuivant votre navigation sur ce site, vous acceptez l'utilisation de cookies pour vous proposer des contenus et services adaptés. Mentions légales.

Recherche

Recherche

Les mémos

Je débute...

Visites

 1218297 visiteurs

 6 visiteurs en ligne

Nous contacter

Contact

Sélection de dossier

Parcourir et Sélectionner un dossier (API)

Retourne le nom du dossier sélectionné

'/
'/ A placer dans la partie déclarative
'/
Private Type BROWSEINFO
    hOwner As Long
    pidlRoot As Long
    pszDisplayName As String
    lpszTitle As String
    ulFlags As Long
    lpfn As Long
    lParam As Long
    iImage As Long
End Type

Private Declare Function SHBrowseForFolder _
                          Lib "shell32.dll" _
                              Alias "SHBrowseForFolderA" _
                              (lpBrowseInfo As BROWSEINFO) As Long

Private Const BIF_RETURNONLYFSDIRS = &H1

Private Declare Function SHGetPathFromIDList _
                          Lib "shell32.dll" _
                              Alias "SHGetPathFromIDListA" _
                              (ByVal pidl As Long, _
                               ByVal pszPath As String) As Long

La fonction :

Public Function GetFolderName(Optional szDialogTitle As Variant) As String
    If IsMissing(szDialogTitle) Then
        szDialogTitle = "Veuillez sélectionner le dossier"
    End If
    Dim x As Long
    Dim bInfo As BROWSEINFO
    Dim dwIList As Long
    Dim szPath As String
    Dim wPos As Integer
    With bInfo
        .hOwner = hWndAccessApp
        .lpszTitle = szDialogTitle
        .pidlRoot = 0&
        .ulFlags = BIF_RETURNONLYFSDIRS
    End With
    dwIList = SHBrowseForFolder(bInfo)
    szPath = Space$(512)
    x = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
    If x Then
        wPos = InStr(szPath, Chr(0))
        GetFolderName = Left$(szPath, wPos - 1)
    Else
        GetFolderName = ""
    End If
End Function

Catégorie : Les mémos - Fichiers
Page lue 6958 fois

Vous êtes ici :   Accueil » Sélection de dossier