J'ai cette fonction qui viens de ??? (merci à lui) j'aimerais quelle
m'affiche le résultat dans la cellule A1 et non pas dans une boite de
dialogue.
Comment faire ?
Merci de votre aide
Option Explicit
Public 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
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As
String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub Recherche()
MsgBox GetDirectory
End Sub
Function GetDirectory(Optional Msg) As String
Dim bInfo As BROWSEINFO
Dim path As String
Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 19&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Selectionnez un dossier."
Else
bInfo.lpszTitle = Msg
End If
'Type de renvoi : dossier
bInfo.ulFlags = &H1
'Type de renvoi : fichier
'bInfo.ulFlags = &H4000
x = SHBrowseForFolder(bInfo)
path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
GetDirectory = Left(path, pos - 1)
Else
GetDirectory = ""
End If
End Function
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
poypoy
Bonjour David,
j'avoue ne pas comprendre la moitié de ta macro (et je n'ai pas le courage de la tester ) mais je sais répondre à ta question ^^ :
Tu remplace Sub Recherche() MsgBox GetDirectory End Sub
p
Bonjour à tous
Débutant +++ Excel 2000 - Windows XP
J'ai cette fonction qui viens de ??? (merci à lui) j'aimerais quelle m'affiche le résultat dans la cellule A1 et non pas dans une boite de dialogue.
Comment faire ?
Merci de votre aide
Option Explicit
Public 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
Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub Recherche() MsgBox GetDirectory End Sub
Function GetDirectory(Optional Msg) As String Dim bInfo As BROWSEINFO Dim path As String Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 19&
If IsMissing(Msg) Then bInfo.lpszTitle = "Selectionnez un dossier." Else bInfo.lpszTitle = Msg End If
'Type de renvoi : dossier bInfo.ulFlags = &H1 'Type de renvoi : fichier 'bInfo.ulFlags = &H4000
x = SHBrowseForFolder(bInfo)
path = Space$(512) r = SHGetPathFromIDList(ByVal x, ByVal path) If r Then pos = InStr(path, Chr$(0)) GetDirectory = Left(path, pos - 1) Else GetDirectory = "" End If End Function
Bonjour David,
j'avoue ne pas comprendre la moitié de ta macro (et je n'ai pas le courage
de la tester ) mais je sais répondre à ta question ^^ :
Tu remplace
Sub Recherche()
MsgBox GetDirectory
End Sub
p
Bonjour à tous
Débutant +++
Excel 2000 - Windows XP
J'ai cette fonction qui viens de ??? (merci à lui) j'aimerais quelle
m'affiche le résultat dans la cellule A1 et non pas dans une boite de
dialogue.
Comment faire ?
Merci de votre aide
Option Explicit
Public 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
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As
String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub Recherche()
MsgBox GetDirectory
End Sub
Function GetDirectory(Optional Msg) As String
Dim bInfo As BROWSEINFO
Dim path As String
Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 19&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Selectionnez un dossier."
Else
bInfo.lpszTitle = Msg
End If
'Type de renvoi : dossier
bInfo.ulFlags = &H1
'Type de renvoi : fichier
'bInfo.ulFlags = &H4000
x = SHBrowseForFolder(bInfo)
path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
GetDirectory = Left(path, pos - 1)
Else
GetDirectory = ""
End If
End Function
j'avoue ne pas comprendre la moitié de ta macro (et je n'ai pas le courage de la tester ) mais je sais répondre à ta question ^^ :
Tu remplace Sub Recherche() MsgBox GetDirectory End Sub
p
Bonjour à tous
Débutant +++ Excel 2000 - Windows XP
J'ai cette fonction qui viens de ??? (merci à lui) j'aimerais quelle m'affiche le résultat dans la cellule A1 et non pas dans une boite de dialogue.
Comment faire ?
Merci de votre aide
Option Explicit
Public 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
Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub Recherche() MsgBox GetDirectory End Sub
Function GetDirectory(Optional Msg) As String Dim bInfo As BROWSEINFO Dim path As String Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 19&
If IsMissing(Msg) Then bInfo.lpszTitle = "Selectionnez un dossier." Else bInfo.lpszTitle = Msg End If
'Type de renvoi : dossier bInfo.ulFlags = &H1 'Type de renvoi : fichier 'bInfo.ulFlags = &H4000
x = SHBrowseForFolder(bInfo)
path = Space$(512) r = SHGetPathFromIDList(ByVal x, ByVal path) If r Then pos = InStr(path, Chr$(0)) GetDirectory = Left(path, pos - 1) Else GetDirectory = "" End If End Function
poypoy
Dsl tromper de bouton, donc tu le remplace par sub recherche() range("a1") = getdirectory end sub
Cordialement Benjamin
Bonjour à tous
Débutant +++ Excel 2000 - Windows XP
J'ai cette fonction qui viens de ??? (merci à lui) j'aimerais quelle m'affiche le résultat dans la cellule A1 et non pas dans une boite de dialogue.
Comment faire ?
Merci de votre aide
Option Explicit
Public 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
Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub Recherche() MsgBox GetDirectory End Sub
Function GetDirectory(Optional Msg) As String Dim bInfo As BROWSEINFO Dim path As String Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 19&
If IsMissing(Msg) Then bInfo.lpszTitle = "Selectionnez un dossier." Else bInfo.lpszTitle = Msg End If
'Type de renvoi : dossier bInfo.ulFlags = &H1 'Type de renvoi : fichier 'bInfo.ulFlags = &H4000
x = SHBrowseForFolder(bInfo)
path = Space$(512) r = SHGetPathFromIDList(ByVal x, ByVal path) If r Then pos = InStr(path, Chr$(0)) GetDirectory = Left(path, pos - 1) Else GetDirectory = "" End If End Function
Dsl tromper de bouton,
donc tu le remplace par
sub recherche()
range("a1") = getdirectory
end sub
Cordialement
Benjamin
Bonjour à tous
Débutant +++
Excel 2000 - Windows XP
J'ai cette fonction qui viens de ??? (merci à lui) j'aimerais quelle
m'affiche le résultat dans la cellule A1 et non pas dans une boite de
dialogue.
Comment faire ?
Merci de votre aide
Option Explicit
Public 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
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As
String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub Recherche()
MsgBox GetDirectory
End Sub
Function GetDirectory(Optional Msg) As String
Dim bInfo As BROWSEINFO
Dim path As String
Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 19&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Selectionnez un dossier."
Else
bInfo.lpszTitle = Msg
End If
'Type de renvoi : dossier
bInfo.ulFlags = &H1
'Type de renvoi : fichier
'bInfo.ulFlags = &H4000
x = SHBrowseForFolder(bInfo)
path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
GetDirectory = Left(path, pos - 1)
Else
GetDirectory = ""
End If
End Function
Dsl tromper de bouton, donc tu le remplace par sub recherche() range("a1") = getdirectory end sub
Cordialement Benjamin
Bonjour à tous
Débutant +++ Excel 2000 - Windows XP
J'ai cette fonction qui viens de ??? (merci à lui) j'aimerais quelle m'affiche le résultat dans la cellule A1 et non pas dans une boite de dialogue.
Comment faire ?
Merci de votre aide
Option Explicit
Public 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
Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub Recherche() MsgBox GetDirectory End Sub
Function GetDirectory(Optional Msg) As String Dim bInfo As BROWSEINFO Dim path As String Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 19&
If IsMissing(Msg) Then bInfo.lpszTitle = "Selectionnez un dossier." Else bInfo.lpszTitle = Msg End If
'Type de renvoi : dossier bInfo.ulFlags = &H1 'Type de renvoi : fichier 'bInfo.ulFlags = &H4000
x = SHBrowseForFolder(bInfo)
path = Space$(512) r = SHGetPathFromIDList(ByVal x, ByVal path) If r Then pos = InStr(path, Chr$(0)) GetDirectory = Left(path, pos - 1) Else GetDirectory = "" End If End Function