[AccessD] Access files by date

Stuart McLachlan stuart at lexacorp.com.pg
Tue Aug 1 16:57:00 CDT 2017



On 2 Aug 2017 at 7:42, Stuart McLachlan wrote:

> On 1 Aug 2017 at 7:56, Rocky Smolin wrote:
> > ' search jpg header fields to find which one is the original date
> ...
> > objFolder.GetDetailsOf(objFolderItem, 16) ' turns out to be field 12
> 
> > GetProperty = objFolder.GetDetailsOf(objFolderItem, 12) 
> 

Based on Rocky's code, I just knocked up a simple little application to get all available 
information about every file in a folder.  Just a table with four fields and the following module.

Option Compare Database
Option Explicit

Function getdata()
Dim s As String
s = Dir$(CurrentProject.Path & "\*.*")
While s > ""
    GetProperties CurrentProject.Path & "\" & s
    s = Dir$
Wend
End Function

Function GetProperties(strFile)
Dim objShell
Dim objFolder
Dim objFolderItem
Dim strPath
Dim strName
Dim intPos
Dim x As Long
Dim rs As DAO.Recordset
'On Error GoTo ErrHandler

intPos = InStrRev(strFile, "\")
strPath = Left(strFile, intPos)
strName = Mid(strFile, intPos + 1)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strPath)
Set objFolderItem = objFolder.ParseName(strName)
If Not objFolderItem Is Nothing Then
Set rs = CurrentDb.OpenRecordset("tblProperties")
For x = 0 To 300
rs.AddNew
rs!FileName = strName
rs!PropNUm = x
rs!Propname = objFolder.GetDetailsOf(objFolder.Items, x)
rs!PropValue = objFolder.GetDetailsOf(objFolderItem, x)
rs.Update
Next
End If

ExitHandler:
Set objFolderItem = Nothing
Set objFolder = Nothing
Set objShell = Nothing
rs.Close
Set rs = Nothing

Exit Function

ErrHandler:
MsgBox Err.Description, vbExclamation
Resume ExitHandler
End Function


More information about the AccessD mailing list