Explorateur windows sous VBA-ACCESS

moktar corp Messages postés 3 Date d'inscription mercredi 17 décembre 2003 Statut Membre Dernière intervention 9 février 2004 - 20 janv. 2004 à 11:07
cs_sammy007 Messages postés 1 Date d'inscription lundi 7 février 2005 Statut Membre Dernière intervention 7 février 2005 - 7 févr. 2005 à 11:54
Bonjour tout le monde!
ou est-ce que je pourrais trouver un explorateur windows simple, exécutable sous VBA?
Merci d'avance
moktar corp

3 réponses

cs_BFR Messages postés 88 Date d'inscription mardi 30 juillet 2002 Statut Membre Dernière intervention 1 mars 2008
20 janv. 2004 à 15:09
'-Tester dans une feuille sous Excel
'-EXPLORATEUR************************************************************

'*******' DECLARATION DES API '********'
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
'*******' DECLARATION DES API '********'
'*******' DECLARATION DES CONSTANTES '********'
Private Const BIF_RETURNONLYFSDIRS = &H1
Private Const BIF_STATUSTEXT = &H4
'*******' DECLARATION DES CONSTANTES '********'
'*******' DECLARATION DES TYPES '********'
Private Type BROWSEINFO 'bi
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 Type SHITEMID 'mkid
cb As Long
abID As Byte
End Type

Private Type ITEMIDLIST 'idl
mkid As SHITEMID
End Type

'-EXPLORATEUR FIN************************************************************

Private Sub CommandButton1_Click()
Dim toto
toto = EXPLORATEUR("Recheche Fichier")
End Sub

Public Function EXPLORATEUR(Optional TexteInfo As String) As String
'-***Appeler l'explorateur***
'-Créer le ?
'-MAJ le 28/01/2002

'-Déclarations
Dim bi As BROWSEINFO
Dim IDL As ITEMIDLIST
Dim pidl As Long
Dim Retval As Long
Dim Pos As Long
Dim Rep_Select As String 'Chemin du répertoire sélectionné

With bi
.hOwner = 0 'Frm.Hwnd '0 (zéro)ou Me.hWnd si on a une Feuille par exemple
.pidlRoot = 0&
.lpszTitle = TexteInfo '-Texte d'info de la feuille
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_STATUSTEXT
End With
'-Espace réservé pour la variable
Rep_Select = Space(512)

pidl& = SHBrowseForFolder(bi)

Retval = SHGetPathFromIDList(ByVal pidl, ByVal Rep_Select)


If Retval Then
'-Recherche la position du caractère (Chr(0))
Pos = InStr(Rep_Select, Chr(0))
'-Selectionne le chemin du dossier à gauche sans le(Chr(0))
'et renvoie dans la fonction
EXPLORATEUR = Left(Rep_Select, Pos - 1)
End If

End Function
A++ BFR
0
moktar corp Messages postés 3 Date d'inscription mercredi 17 décembre 2003 Statut Membre Dernière intervention 9 février 2004
21 janv. 2004 à 11:29
tout marche très bien
merci à toi BFR
moktar corp
0
cs_sammy007 Messages postés 1 Date d'inscription lundi 7 février 2005 Statut Membre Dernière intervention 7 février 2005
7 févr. 2005 à 11:54
Bonjour à Tous,

J'ai bien utilisé ce petit prog qui est excellent, toutefois, j'ai besoin de rechercher des fichiers. Existe t-il un moyen de voir le nom des fichiers en plus des dossiers ?

Merci,

Sammy.
0
Rejoignez-nous