
Get document Properties with code
Quote:
> I have a bit of code that gets the directory and filenames but what I
> want to do is enumerate through the filenames and get the properties.
> I am particularly interested in last modified date and some others.
You will need to be specific about the requirements. As Allen has mentioned,
VBA allows you to get to most such props, but not all of them. For the rest,
you can use the API functions, a sample of which is available as a dll (w/
source) at: (snippet of relevant function copied below)
[ http://www.mvps.org/access/modules/mdl0051.htm ]
' ****** Code Start *****
Public Function GetInfoForFile(ByVal FileName As String) As File
' This function can be used to get to the Details info of File Class
' without performing a search for the file.
' This proc is the reason why this class is MultiUse.
'
On Error GoTo ErrHandler
Dim lpFileInfo As BY_HANDLE_FILE_INFORMATION
Dim hFile As Long, lngRet As Long, clsFile As File
' Get a handle to the file
hFile = apiCreateFile(FileName, _
GENERIC_READ, FILE_SHARE_READ, 0, _
OPEN_EXISTING, 0, 0)
If Not hFile = INVALID_HANDLE_VALUE Then
lngRet = apiGetFileInformationByHandle(hFile, lpFileInfo)
If Not lngRet = 0 Then
' If the file info was successfully retrieved,
' then instantiate a new File object and fill it with info.
Set clsFile = New File
With clsFile
.FullPath = FileName
.Name = Dir(FileName, vbHidden Or vbSystem)
.Attributes = lpFileInfo.dwFileAttributes
.TimeCreated = fGetFileTime(VarPtr(lpFileInfo), 1, 2)
.TimeLastAccessed = fGetFileTime(VarPtr(lpFileInfo), 2, 2)
.TimeLastWritten = fGetFileTime(VarPtr(lpFileInfo), 3, 2)
.Size = ((lpFileInfo.nFileSizeHigh * (MAXDWORD + 1)) +
lpFileInfo.nFileSizeLow)
.TypeName = fGetFileDesc(.FullPath)
Call sGetFileVersion(clsFile)
.IEVersion = WIN32_IE
End With
End If
End If
' Return the file back
Set GetInfoForFile = clsFile
ExitHere:
Set clsFile = Nothing
Call apiCloseHandle(hFile)
Exit Function
ErrHandler:
With Err
.Raise .Number, .Source, .Description, .HelpFile, .HelpContext
End With
Resume ExitHere
End Function
' ***** Code End ******
-- Dev