Boa tarde, peguei um código de VB para listar os arquivos de um diretório, mas esbarrei no fato de que o código contém o Application.FileSearch e meu Excel é 2010.
Há como fazer este mesmo procedimento para o Excel 2010?
Segue código:
Sub ListDirectory()
Dim Msg As String
Dim rw As String
Dim i As Long
Dim sDir As String
Msg = InputBox("Escolha o Path:")
sDir = Msg
If Len(Trim(Msg)) = 0 Then
MsgBox "Não seleccionou nada..."
Exit Sub
End If
Option Explicit
'*
'* Properties that will be collected for each found file
'*
Type FoundFileInfo
sPath As String
sName As String
End Type
With Application.FileSearch
.NewSearch
.LookIn = sDir
.SearchSubFolders = True
.Filename = "*.*"
.FileType = msoFileTypeAllFiles
rw = 2
If .Execute() > 0 Then
Sheets("Sheet1").Range("A:A").Clear
For i = 1 To .FoundFiles.Count
Sheets("Sheet1").Cells(rw, "A").Value = Dir(.FoundFiles(i))
Sheets("Sheet1").Cells(rw, "B").Value = FileDateTime(.FoundFiles(i))
rw = rw + 1
Next i
Else
MsgBox "Não foram encontrados ficheiros"
End If
End With
Sheets("Sheet1").Cells(1, 1).Value = "Nome do Ficheiro"
Sheets("Sheet1").Cells(1, 2).Value = "Data/Hora"
Columns("A:B").AutoFit
End Sub
Luccas.Ceche...
Novo Membro
Registrado
6 Mensagens
0 Curtidas
Application.FileSearch equivalente para o Visual Basic do Excel 2010?
#1 Por Luccas.Ceche...
26/11/2014 - 15:49