Bonjour
c'est bon j'ai trouvé une solution !!!
Apres multiples tentative, je vous laisse le code
les solutions sur ces deux postes :
http://codes-sources.commentcamarche.net/forum/affich-15102-selectionner-un-repertoire-avec-une-boite-de-dialogue-en-vba
http://www.cadsharp.com/blog/solidworks-macro-compatible-64-vba7/
à modifier selon votre bon vouloir :
Private Type BROWSEINFO ' used by the function GetFolderName
hOwner As LongPtr
pidlRoot As LongPtr
pszDisplayName As String
lpszTitle As String
ulFlags As LongPtr
lpfn As LongPtr
lParam As LongPtr
iImage As LongPtr
End Type
#If VBA7 Then
Private Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As LongPtr, ByVal pszPath As String) As LongPtr
Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As LongPtr
#Else
'Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As LongPtr, ByVal pszPath As String) As Long
'Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
#End If
Function GetFolderName(Msg As String) As String
' returns the name of the folder selected by the user
Dim bInfo As BROWSEINFO, path As String, r As LongPtr, x As LongPtr, pos As Integer
'bInfo.pidlRoot 0& ' Root folder Desktop
If IsMissing(Msg) Then
bInfo.lpszTitle = "Selectionner un répertoire de travail" ' the dialog title
Else
bInfo.lpszTitle = Msg ' the dialog title
End If
bInfo.ulFlags = &H1 ' Type of directory to return
x = SHBrowseForFolder(bInfo) ' display the dialog
' Parse the result
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
Private Sub CommandButton2_Click()
Dim Rep0 As String
Rep0 = GetFolderName("Choisissez un répertoire de travail")
FrmE2S.TextBox1.Text = Rep0
End Sub