Comment traduire "Lire Rep" en VBA????

Fermé
nanaiti Messages postés 1 Date d'inscription vendredi 17 avril 2009 Statut Membre Dernière intervention 17 avril 2009 - 17 avril 2009 à 09:49
ghuysmans99 Messages postés 2496 Date d'inscription jeudi 14 juillet 2005 Statut Contributeur Dernière intervention 5 juin 2016 - 17 avril 2009 à 10:15
Bonjour,
Je suis étudiante à la fac et j'ai un petit problème qui m'empêche de tester mon programme, je ne sais pas comment traduire "lire" en VBA.
Merci d'avance pour votre aide.
Nanaiti
A voir également:

2 réponses

ghuysmans99 Messages postés 2496 Date d'inscription jeudi 14 juillet 2005 Statut Contributeur Dernière intervention 5 juin 2016 339
17 avril 2009 à 09:53
Tu veux énumérer le contenu d'un dossier ?
Il te suffit de changer le contenu du 1er cas du sub Handler :

Option Explicit

Private Const MAX_PATH As Long = 260
Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10

Private Type T_SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Private Type T_FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Private Type T_WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As T_FILETIME
ftLastAccessTime As T_FILETIME
ftLastWriteTime As T_FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type

Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Private Declare Function FindFirstFile Lib "kernel32.dll" Alias "FindFirstFileA" (ByVal lpFileName As String, ByRef lpFindFileData As T_WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32.dll" Alias "FindNextFileA" (ByVal hFindFile As Long, ByRef lpFindFileData As T_WIN32_FIND_DATA) As Long
Private Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (ByRef Destination As Any, ByVal Length As Long)

Public Sub ListFiles(Path As String, Filter As String, Optional Recursive As Boolean = False)
Dim hFiles As Long
Dim FD As T_WIN32_FIND_DATA, FN As String
Dim FileName As String
If Right(Path, 1) <> "\" And Right(Path, 1) <> "/" Then Path = Path & "\"
hFiles = FindFirstFile(Path & Filter, FD)
If hFiles = -1 Then Exit Sub
Do
FN = Left(FD.cFileName, InStr(1, FD.cFileName, Chr(0)) - 1)
If FN <> "." And FN <> ".." And FN <> vbNullString Then
If FD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
If Recursive Then
Handler 2, Path & FN
ListFiles Path & FN, Filter, True
End If
Else
Handler 1, Path & FN
End If
End If
Loop While FindNextFile(hFiles, FD) <> 0
CloseHandle hFiles
End Sub

Private Sub Handler(Msg As Integer, Optional FileName As String = "")
Select Case Msg
Case 1
'New listed file
DoEvents
Case 2
'Entering in directory
DoEvents 'Do nothing
End Select
End Sub
0
Bonjour

C'est de l'humour, ghuysmans99 ?
Il y a l'instruction "Dir", un peu plus facile à utiliser
0
ghuysmans99 Messages postés 2496 Date d'inscription jeudi 14 juillet 2005 Statut Contributeur Dernière intervention 5 juin 2016 339
17 avril 2009 à 10:15
Euh non.
Ma fonction est déjà récursive, prête à l'emploi ...
0