Here's another way. No harm in seeing more then one way. The following loops through a directory, but you can modify it to just do one file.
I created a listbox on a form, setting Row Source Type to Value List.
I then created a command button with the following code on OnClick event:
Private Sub Command2_Click()
Dim strFill As String
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\excelforcourse")
For Each strFileName In objFolder.Items
strFill = strFill & strFileName & " " & objFolder.GetDetailsOf(strFileName, 3) & ";"
Next
ListProps.RowSource = strFill
End Sub
strFill statement is on one line.
You'll notice the 3 in the GetDetailsOF - that the Date Modified index. There's 34 properties of a file you can retrieve this way.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.