Bonjour à tous
J'utilise dans vba le browser windows pour pouvoir selectionner un dossier ou un lecteur particulier, jusque là pas de problème. voici le code:
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
| Option Compare Database
Option Explicit
Private Type BrowseInfo
sDisplayName As String
hWndOwner As Long
sTitle As String
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 SHGetPathFromIDList Lib "Shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "Shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BrowseInfo) As Long
Private Const BIF_RETURNONLYFSDIRS = &H1
Private Declare Function GetDriveTypeA Lib "kernel32" (ByVal nDrive As String) As Long
Private Enum DRIVE_TYPE
UNKNOWN = 0
DRIVE_NO_ROOT_DIR = 1
REMOVABLE = 2
FIXED = 3
REMOTE = 4
CDROM = 5
RAMDISK = 6
End Enum
Public Function BrowseFolder(szDialogTitle As String) As String
Dim X As Long, bi As BrowseInfo, dwIList As Long
Dim szPath As String, wPos As Integer
With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
Debug.Print hWndAccessApp
Debug.Print szDialogTitle
Debug.Print BIF_RETURNONLYFSDIRS
End With
dwIList = SHBrowseForFolder(bi)
Debug.Print dwIList
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If X Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Debug.Print wPos
Debug.Print BrowseFolder
Else
BrowseFolder = ""
End If
End Function |
Ma question est la suivante :
Est-il possible de ne faire afficher que certain lecteur ?
Je désire ne faire afficher dans le browser que les disques amovible (removable disque).
Si quelqu'un à un bout de code ou une idée, je l'en remerci d'avance.
Cordialement