Get document Properties with code 
Author Message
 Get document Properties with code

Dir()
FileDateTime()
GetAttr()

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.  I've searched help but to no
> avail.  Can anyone enlighten me?

--
Perth, Western Australia
Tips for MS Access users at:
        http://www.*-*-*.com/ ~abrowne


Sat, 06 Dec 2003 23:21:40 GMT  
 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



Sun, 07 Dec 2003 01:14:53 GMT  
 Get document Properties with code

Yes indeed, how could I overlook that?

It works.

Thanks Allen

Quote:
-----Original Message-----

Dir()
FileDateTime()
GetAttr()


> 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.  I've searched help but to no
> avail.  Can anyone enlighten me?

--
Perth, Western Australia
Tips for MS Access users at:
        http://odyssey.apana.org.au/~abrowne
.



Sun, 07 Dec 2003 02:08:23 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getting Word Properties from an open document

2. Getting a built-in document property

3. Problems while getting properties of Document.Range - Object

4. getting a document description from a word document

5. Getting embedded document file names from parent document

6. populating document properties from text in document

7. Accessing Office Custom Document Properties from Closed Documents/Workbooks

8. Custom DB properties and Document Properties (A97)

9. VBA code to print all icon-inserted documents within a document

10. removing code from a document created via code and save as

11. getting a value from an excel document.

12. Getting the words of the first line of a document

 

 
Powered by phpBB® Forum Software