Quang_Hải
Thành viên gạo cội




- Tham gia
- 21/2/09
- Bài viết
- 6,074
- Được thích
- 8,004
- Nghề nghiệp
- Làm đủ thứ
Các anh chị xem giúp tại sao code này bị lỗi Input past end of file
Một số folder thì lấy được file, 1 số folder thì bị lỗi dù trong folder có chứa file.
Không biết có phải vì sai câu lệnh Scomm
Một số folder thì lấy được file, 1 số folder thì bị lỗi dù trong folder có chứa file.

Không biết có phải vì sai câu lệnh Scomm
PHP:
Sub GetFiles()
Dim sComm As String, tmpFile, path, Res, i
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show Then
path = .SelectedItems(1)
If Right(path, 1) <> "\" Then path = path & "\"
With CreateObject("Scripting.FileSystemObject")
tmpFile = "D:\" & .GetTempName
sComm = "DIR " & path & "/A-D/B/C/D/O/N/S > " & tmpFile
CreateObject("Wscript.Shell").Run "cmd /c " & sComm, 0, True
Res = Split(.OpenTextFile(tmpFile, 1).ReadAll, vbCrLf)
Kill tmpFile
End With
MsgBox UBound(Res)
End If
End With
End Sub
Lần chỉnh sửa cuối: