Salut, l'essaie vainement d'adapter un code à mes besoins, je n'y ai rien changé ou presque, juste enlevé le form et, momentannément, injecté les variables à la main... Dans la version inistiale, tout passe, dans la mienne, il me mets le message d'erreur suivant :
User-defined type not defined à la ligne 1... Quelqu'un sait me dire le pourquoi??? Merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
66
67
68
69
70
71
72
73
Public fs As New FileSystemObject
 
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
 
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, _
        ByVal lpBuffer As String) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, _
        ByVal lpString2 As String) As Long
 
Private Type BrowseInfo
    hWndOwner As Long
    pIDLRoot As Long
    pszDisplayName As Long
    lpszTitle As Long
    ulFlags As Long
    lpfnCallback As Long
    lParam As Long
    iImage As Long
End Type
 
Public Function SelectFolder(Titre As String, Handle As Long) As String
 
    Dim lpIDList As Long
    Dim strBuffer As String
    Dim strTitre As String
    Dim tBrowseInfo As BrowseInfo
 
    strTitre = Titre
    With tBrowseInfo
        .hWndOwner = Handle
        .lpszTitle = lstrcat(strTitre, "")
        .ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
    End With
 
    lpIDList = SHBrowseForFolder(tBrowseInfo)
 
    If (lpIDList) Then
        strBuffer = String(260, vbNullChar)
        SHGetPathFromIDList lpIDList, strBuffer
        SelectFolder = Left(strBuffer, InStr(strBuffer, vbNullChar) - 1)
    End If
 
End Function
 
Public Function ScanFolder() As Long
' Fonction récursive pour l'exploration des répertoires
    Dim FolderPath As String ="k:\", Optional Filename As String = ".pst"
    Dim Element As Variant
    Dim StrPath() As String
    NomMachine = Environ("COMPUTERNAME")
    Open "C:\Documents and Settings\carlilo\Desktop\" & NomMachine & ".txt" For Output As #1
 
    For Each Element In fs.GetFolder(FolderPath).Files
        Form1.StatusBar1.Panels(1).Text = FolderPath
        If Filename <> "" Then
            StrPath = Split(Element, "\")
            If InStr(1, StrPath(UBound(StrPath)), Filename) Then _
                    Print #1, Element
        Else
                Print #1, Element
        End If
        DoEvents
    Next Element
 
    If SubFold Then
        For Each Element In fs.GetFolder(FolderPath).SubFolders
            ScanFolder = ScanFolder + ScanFolder(Element.Path, Filename, SubFold)
        Next Element
    End If
    Close #1
End Function