This Code is working fine on my local drive... but not on Share Drive.... I have been trying for this for long... but no luck yet.... Please some one help me in this...
Below is the code to get the list of files in a directory on local drive. Is there any way to do the same on share drive on server...
[TABLE="width: 100%"]
<tbody>[TR]
[TD]Dim iRow As Long 'start row to put output
Dim pathf As String 'pathfolder
Dim subf As Boolean 'incl subfolders true/false
Dim Fdate, Tdate As Date
Dim intC As Integer
Sub ListFiles()
Application.ScreenUpdating = False
wksList.Activate
wksList.Range("D8").FormulaR1C1 = "=COUNTA(R[-6]C[2]:R[49992]C[2])"
intC = wksList.Range("D8").Value
wksList.Range("F2:H2").ClearContents
wksList.Range("F3:H" & intC + 1).Clear
iRow = 2
pathf = wksList.Range("D2").Value
subf = True
Call ListMyFiles(pathf, subf)
intC = wksList.Range("D8").Value
wksList.Range("F2:H2").Copy
wksList.Range("F2:H" & intC + 1).PasteSpecial xlPasteFormats
Application.CutCopyMode = False
wksList.Range("D8").Value = wksList.Range("D8").Value
wksList.Range("F1").Select
ActiveWorkbook.Worksheets("List").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("List").AutoFilter.Sort.SortFields.Add Key:=Range( _
"H1:H8"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("List").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set mySource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
Fdate = wksList.Range("D3").Value
Tdate = wksList.Range("D4").Value + 1
For Each myFile In mySource.Files
If myFile.DateLastModified <= Tdate And myFile.DateLastModified >= Fdate Then
iCol = 6
Cells(iRow, iCol).Value = myFile.Name
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Path
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.DateLastModified
iRow = iRow + 1
End If
Next
If IncludeSubfolders Then
For Each mySubFolder In mySource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
Next
End If
End Sub
[/TD]
[/TR]
</tbody>[/TABLE]
Thanks a million in advance