2008-11-15 13 views

Respuesta

15
sFilename = Dir(sFoldername) 

Do While sFilename > "" 

    debug.print sFilename 
    sFilename = Dir() 

Loop 
+0

Maldición, pásame: P Tenga un artículo de MSDN para referencia: http://msdn.microsoft.com/en-us/library/aa262726(VS.60).aspx –

4

de DJ solution es simple y eficaz, simplemente tirar otro en caso de que necesite un poco más de funcionalidad que puede proporcionar FileSystemObject (requiere una referencia a la Microsoft Scripting Runtime).

Dim fso As New FileSystemObject 
Dim fil As File 

For Each fil In fso.GetFolder("C:\").Files 
    Debug.Print fil.Name 
Next 
9
Dim fso As New FileSystemObject 
Dim fld As Folder 
Dim fil As File 
Set fld = fso.GetFolder("C:\My Folder") 
For Each fil In fld.Files 
    Debug.Print fil.Name 
Next 
Set fil = Nothing 
Set fld = Nothing 
Set fso = Nothing 
0

botón con el nombre = browseButton crear FileListBox con el nombre create = Lista1

haga doble clic en el botón en el diseño

y el código debería tener este aspecto

Private Sub browseButton_Click() 

Dim path As String 
path = "C:\My Folder" 

List1.path() = path 
List1.Pattern = "*.txt" 
End Sub 

hecho ahora ejecutarlo

Cuestiones relacionadas