Reading File Attributes using FSO

colins5286

New member
Local time
Yesterday, 21:31
Joined
Feb 13, 2007
Messages
9
I have a table which contains file names and locations. I then display these on a form. The form has unbound fields on it such as DateLastModified, DateCreated.
I would like to use VBA to retrieve the information from the file. I have some code which displays a few fields but I am unable to get it to display information from the 'summary' of the file properties. Keywords, Category etc...
The code I have so far has been placed in the OnCurrent event of the form.

Code:
Private Sub Form_Current()
'Set the file details
    Dim f As File
    Dim fso As New FileSystemObject
    Dim namedfile As String
    namedfile = FileName 'This is the only bound field on the form
    Set f = fso.GetFile(namedfile)
    
'Set the unbound fields on the form
    Me!datelastmod = CStr(f.DateLastModified)
    Me!attr = CStr(f.Attributes)

End Sub

I would like additional fields to be displayed. Any help would be much appreciated.
Thanks
Colin
 
You need bitwise comparison to get at the file attributes. See http://msdn2.microsoft.com/en-us/library/5tx15443.aspx for codes, i e (air code)
Code:
If f.Attributes and Normal Then 
    msgbox "no attributes set"
End If
If f.Attributes and Archive Then 
    msgbox "Archive attribute set"
End If
If f.Attributes and ReadOnly Then 
    msgbox "ReadOnly attribute set"
End If
...
 
Thanks for that one, but it is the summary attributes I need to display such as the Keywords, Category, Author, Comments etc...
Thanks
 
Thats looks like what I am trying to do - Just need to read it a few times to understand how to implement it on my database.

Thanks very much
 

Users who are viewing this thread

Back
Top Bottom