Code:
With wbkResults.Worksheets("Sheet1")
r = .Range("A65536").End(xlUp).Row + 1
On Error Resume Next
For Each FileItem In SourceFolder.Files
Call StatusMonitor(FileItem.Path)
' display file properties
.Cells(r, 1).Formula = FileItem.Path ' & FileItem.Name
.Cells(r, 2).Formula = FileItem.Size
.Cells(r, 3).Formula = FileItem.Type
.Cells(r, 4).Formula = FileItem.DateCreated
.Cells(r, 5).Formula = FileItem.DateLastAccessed
.Cells(r, 6).Formula = FileItem.DateLastModified
.Cells(r, 7).Formula = FileItem.Attributes
.Cells(r, 8).Formula = FileItem.ShortPath ' 8 character filename
' .Cells(r, 9).Formula = FileItem.Path
On Error Resume Next
.Cells(r, 10).Formula = FileItem.Name
On Error GoTo 0
.Cells(r, 9).FormulaR1C1 = "=SUBSTITUTE(RC[-8],RC[1],"""",1)"
.Cells(r, 9).Value = .Cells(r, 9).Value
On Error GoTo 0
r = r + 1 ' next row number
[red]Next FileItem[/red]
End With
Now at this point r = 9850 so the loop was ok the previous 9849 times!
Just to say this error was obtained by a co-worker. When I ran the last week all was fine.
We are trying to document file locations prior to a massive re-structuring of folders etc. The other issue is that the macro is apparently finding more files than explorer reports if you right-click a folder and ask for properties.
Gavin