Toto by malo fungovať...
Function ZoznamSuborov(Adresar As String) As Variant
Dim FSO As Object, Subor As Object, Zoznam() As String, Pocet As Long
On Error GoTo KONIEC
Set FSO = CreateObject("Scripting.FileSystemObject").GetFolder(Adresar)
On Error GoTo 0
Pocet = FSO.Files.Count
If Pocet > 0 Then
ReDim Zoznam(1 To Pocet)
Pocet = 0
For Each Subor In FSO.Files
Pocet = Pocet + 1
Zoznam(Pocet) = Subor.Name
Next Subor
ZoznamSuborov = Zoznam
End If
KONIEC:
Set FSO = Nothing: Set Subor = Nothing
End Function
Sub pokus()
Dim Vysledok
Vysledok = ZoznamSuborov("\\Elnino-pc\Download D\")
If IsArray(Vysledok) Then
ActiveSheet.Cells(1, 1).Resize(UBound(Vysledok)).Value2 = Application.Transpose(Vysledok)
Else
MsgBox ("Niesú žiadne súbory")
End If
End Subcitovat
Function ZoznamSuborov(Adresar As String) As Variant
Dim FSO As Object, Subor As Object, Zoznam() As String, Pocet As Long
On Error GoTo KONIEC
Set FSO = CreateObject("Scripting.FileSystemObject").GetFolder(Adresar)
On Error GoTo 0
Pocet = FSO.Files.Count
If Pocet > 0 Then
ReDim Zoznam(1 To Pocet)
Pocet = 0
For Each Subor In FSO.Files
Pocet = Pocet + 1
Zoznam(Pocet) = Subor.Name
Next Subor
ZoznamSuborov = Zoznam
End If
KONIEC:
Set FSO = Nothing: Set Subor = Nothing
End Function
Sub pokus()
Dim Vysledok
Vysledok = ZoznamSuborov("\\Elnino-pc\Download D\")
If IsArray(Vysledok) Then
ActiveSheet.Cells(1, 1).Resize(UBound(Vysledok)).Value2 = Application.Transpose(Vysledok)
Else
MsgBox ("Niesú žiadne súbory")
End If
End Subcitovat