close

I want to run an MSQuery on all the spreadsheets on my network drive, to find
when they were last modified/accessed!

Would it be possible in MSQuery or easier in VB?
Can anyone suggest a way to do it?

Thanks
Dean

This is no job for MSQUERY

Since you are in an EXCEL NG, use VBA.
Look at FilesSearch in Help

HTH
--
AP

quot;Deanquot; gt; a écrit dans le message de news:
...
gt;I want to run an MSQuery on all the spreadsheets on my network drive, to
gt;find
gt; when they were last modified/accessed!
gt;
gt; Would it be possible in MSQuery or easier in VB?
gt; Can anyone suggest a way to do it?
gt;
gt; Thanks
gt; Dean
Sub ListFileAttributes()
Dim FSO As Object
Dim i As Long
Dim sFolder As String
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object
Dim this As Workbook
Dim aryFiles
Dim cnt As Long
Dim sh As Worksheet

Set FSO = CreateObject(quot;Scripting.FileSystemObjectquot;)

Set this = ActiveWorkbook
sFolder = quot;C:\MyTestquot;
Set Folder = FSO.GetFolder(sFolder)

ReDim aryFiles(1 To 3, 1 To 1)
Set Files = Folder.Files
cnt = 0
For Each file In Files
If file.Type = quot;Microsoft Excel Worksheetquot; Then
cnt = cnt 1
ReDim Preserve aryFiles(1 To 3, 1 To cnt)
aryFiles(1, cnt) = file.Path
aryFiles(2, cnt) = Format(file.DateLastModified, quot;dd mmm yyyy
hh:mm:ssquot;)
aryFiles(3, cnt) = Format(file.DateCreated, quot;dd mmm yyyy
hh:mm:ssquot;)
End If
Next file

On Error Resume Next
Set sh = Worksheets(quot;ListOfFilesquot;)
On Error GoTo 0
If sh Is Nothing Then
Worksheets.Add.Name = quot;ListOfFilesquot;
Else
sh.Cells.ClearContents
End If

For i = LBound(aryFiles, 2) To UBound(aryFiles, 2)
Cells(i 1, quot;Aquot;).Value = aryFiles(1, i)
Cells(i 1, quot;Bquot;).Value = aryFiles(2, i)
Cells(i 1, quot;Cquot;).Value = aryFiles(3, i)
Next i
Range(quot;A1quot;).Value = quot;Filenamequot;
Range(quot;B1quot;).Value = quot;Modifiedquot;
Range(quot;C1quot;).Value = quot;Createdquot;
Columns(quot;A:Cquot;).AutoFit

End Sub
--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

quot;Deanquot; gt; wrote in message
...
gt; I want to run an MSQuery on all the spreadsheets on my network drive, to
find
gt; when they were last modified/accessed!
gt;
gt; Would it be possible in MSQuery or easier in VB?
gt; Can anyone suggest a way to do it?
gt;
gt; Thanks
gt; Dean

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()