Hello everyone,
These codes below are very basic code for getting the filenames in a folder. However, only one user of my teams can't get the filenames.
When the user executes the test1 code, the macro gets the path, but can't get the filenames. (No error)
When the user executes the FSO code, the macro can't even get the path and displays Err76.
Any help would be greatly appreciated.
These codes below are very basic code for getting the filenames in a folder. However, only one user of my teams can't get the filenames.
When the user executes the test1 code, the macro gets the path, but can't get the filenames. (No error)
When the user executes the FSO code, the macro can't even get the path and displays Err76.
Any help would be greatly appreciated.
VBA Code:
Sub test1()
Dim buf As String, cnt As Long
Dim path As String
path = Environ("UserProfile") & "\Box\test\"
buf = Dir(path)
Do While buf <> ""
cnt = cnt + 1
Sheets("sheet1").Cells(cnt + 9, 2) = buf
buf = Dir()
Loop
End Sub
VBA Code:
Sub FSO()
Dim FSO As Object
Dim Fld, Fl, F
Dim i As Long
Dim path As String
path = Environ("UserProfile") & "\Box\test\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fld = FSO.GetFolder(path)
Set Fl = Fld.Files
i = 10
For Each F In Fl
Cells(i, 3).Value = F.Name
i = i + 1
Next
End Sub