Skip to content

Instantly share code, notes, and snippets.

@gutosantos1

gutosantos1/code Secret

Created February 24, 2021 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gutosantos1/27fb78be22a6dfde7a3c7d7c0c39ab16 to your computer and use it in GitHub Desktop.
Save gutosantos1/27fb78be22a6dfde7a3c7d7c0c39ab16 to your computer and use it in GitHub Desktop.
Sub ListarDocumentos()
Dim caminhoPasta As String
Dim FSO As New FileSystemObject
Dim NomeArq As String, filepath As String
Dim myFolder As Folder
Dim myFile As File
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
caminhoPasta = ThisWorkbook.Worksheets(1).Cells(2, 5).Value
Range("A2:B200").ClearContents
Set myFolder = FSO.GetFolder(caminhoPasta) 'Comando para abrir a pasta no caminho definido em myPath
i = 2
For Each myFile In myFolder.Files 'Loop que pega cada arquivo contido na pasta
NomeArq = myFile.Name
ThisWorkbook.Worksheets(1).Cells(i, 1).Value = NomeArq
ThisWorkbook.Worksheets(1).Cells(i, 2).Value = NomeArq
i = i + 1
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment