Hi, I wonder if someone could help me please.
Using a source file I found here:http://www.learnexcelmacro.com/wp/20...d-sub-folders/, I've put together the following code which downloads a list of files when the workbook opens.
Sub btnFetchFiles()
iRow = 14
fPath = "XXXXXXXXXX"
Const strPattern As String = "*.dat"
If fPath <> "" Then
Set FSO = New Scripting.FileSystemObject
If FSO.FolderExists(fPath) <> False Then
Set SourceFolder = FSO.GetFolder(fPath & strPattern)
IsSubFolder = True
Call ListFilesInFolder(SourceFolder, IsSubFolder)
Call ResultSorting(xlAscending, "C14", "D14", "E14")
Call ListFilesInFolderXtn(SourceFolder, IsSubFolder)
Call ResultSorting(xlAscending, "C14", "D14", "E14")
lblFCount.Caption = iRow - 14
Else
MsgBox "Selected Path Does Not Exist !!" & vbNewLine & vbNewLine & "Select Correct One and Try Again !!", vbInformation, "File Manager - http://www.LearnExcelMacro.Com"
End If
Else
MsgBox "Folder Path Can not be Empty !!" & vbNewLine & vbNewLine & "", vbInformation, "File Manager - http://www.LearnExcelMacro.Com"
End If
End Sub
The problem I have is with this line:
Set SourceFolder = FSO.GetFolder(fPath & strPattern)
where I'm trying to list a specific file type, but when I run the code I recieve a 'Path not found' error.
I know the fPath is correct, but I just wondered whether someone could point out where I've gone wrong on trying to download a specific file type.
Many thanks and kind regards
Chris
Bookmarks