Am I missing a reference object? Trying to retrieve a list of files in a directory and have them show in a sheet.
Also, would it be possible to get the directory location from a specific cell in the file?
Sub LoopThroughFiles()
Dim oFSO As Object
Dim oFolder As Object
Dim oFile As Object
Dim i As Integer
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("C:\VBA Folder")
For Each oFile In oFolder.Files
Cells(i + 1, 1) = oFile.Name
i = i + 1
Next oFile
End Sub
Here:
Set oFSO = CreateObject("Scripting.FileSystemObject")
Runtime error 429 on a Windows machine.
Scripting.FileSystemObjectshould be available on all Windows machines, so I don't know what you are missing. I tested by copy-and-pasting into a new spreadsheet and it worked oob. Maybe you need elevated permissions??