Selection d'un repertoir

Résolu
calitoli Messages postés 45 Date d'inscription jeudi 26 juin 2008 Statut Membre Dernière intervention 7 septembre 2012 - 23 juil. 2008 à 11:24
calitoli Messages postés 45 Date d'inscription jeudi 26 juin 2008 Statut Membre Dernière intervention 7 septembre 2012 - 23 juil. 2008 à 11:44
Bonjour à tous,

J'ai utilisé le code ci-dessous pour selectionner un repertoir. Et comme erreur obtenu lorsque je lance mon application: "Can't find project or library" en selectionnant la variables "Space$".

Aidez-moi SVP.

Merci
code:
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 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



Function GetFolderName(Msg As String) As String
' Retourne le nom du repertoire selectionner
Dim bInfo As BROWSEINFO, path As String, r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Selectionner un répertoire de travail" ' the dialog title
Else
bInfo.lpszTitle = Msg
End If
bInfo.ulFlags = &H1
'Ouvre le dialog
x = SHBrowseForFolder(bInfo)
path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
GetFolderName = Left(path, pos - 1)
Else
GetFolderName = ""
End If
End Function
'===========================






-Calito

2 réponses

mortalino Messages postés 6786 Date d'inscription vendredi 16 décembre 2005 Statut Membre Dernière intervention 21 décembre 2011 18
23 juil. 2008 à 11:38
salut,

si c'est le bug auquel je pense, rajoute devant ton Space la librairie :
path = Strings.Space$(512)

@++

le mystérieux chevalier,"Provençal, le gaulois"
Forum Office & VBA
3
calitoli Messages postés 45 Date d'inscription jeudi 26 juin 2008 Statut Membre Dernière intervention 7 septembre 2012
23 juil. 2008 à 11:44
Okey, c'est bon maintenant. Je l'ai ajouté egalement pour Chr$.


Merci infiniment Mortalino.



-Calito
0
Rejoignez-nous