Discussion:
Getting File Info using GetDetailsOf with specific values
(too old to reply)
Databeheer Quantore
2023-03-01 15:57:25 UTC
Permalink
How can I define a value with 'Getting File Info using GetDetailsOf'

I'd like to list the files of a specific user.

Code is not mine, but the basics work for me. Is there anyone who can help me or point me in the right direction? Thanks!!!


Dim NewSht As Worksheet
Dim MainFolderName As String
Dim TimeLimit As Long, StartTime As Double

ReDim X(1 To 65536, 1 To 11)

Set objShell = CreateObject("Shell.Application")
TimeLimit = Application.InputBox("Please enter the maximum time that you wish this code to run for in minutes" & vbNewLine & vbNewLine & _
"Leave this at zero for unlimited runtime", "Time Check box", 0)
StartTime = Timer

Application.ScreenUpdating = False
MainFolderName = BrowseForFolder()
Set NewSht = ThisWorkbook.Sheets.Add

X(1, 1) = "Path"
X(1, 2) = "File Name"
X(1, 3) = "Last Accessed"
X(1, 4) = "Last Modified"
X(1, 5) = "Created"
X(1, 6) = "Type"
X(1, 7) = "Size"
X(1, 8) = "Owner"
X(1, 9) = "Author"
X(1, 10) = "Title"
X(1, 11) = "Comments"

i = 1

Set FSO = CreateObject("scripting.FileSystemObject")
Set oFolder = FSO.GetFolder(MainFolderName)
'error handling to stop the obscure error that occurs at time when retrieving DateLastAccessed
On Error Resume Next
For Each Fil In oFolder.Files
Set objFolder = objShell.Namespace(oFolder.Path)
Set objFolderItem = objFolder.ParseName(Fil.Name)
i = i + 1
If i Mod 20 = 0 And TimeLimit <> 0 And Timer > (TimeLimit * 60 + StartTime) Then
GoTo FastExit
End If
If i Mod 50 = 0 Then
Application.StatusBar = "Processing File " & i
DoEvents
End If
X(i, 1) = oFolder.Path
X(i, 2) = Fil.Name
X(i, 3) = Fil.DateLastAccessed
X(i, 4) = Fil.DateLastModified
X(i, 5) = Fil.DateCreated
X(i, 6) = Fil.Type
X(i, 7) = Fil.Size
X(i, 8) = objFolder.GetDetailsOf(objFolderItem, 8)
X(i, 9) = objFolder.GetDetailsOf(objFolderItem, 9)
X(i, 10) = objFolder.GetDetailsOf(objFolderItem, 10)
X(i, 11) = objFolder.GetDetailsOf(objFolderItem, 14)
Next

'Get subdirectories
If TimeLimit = 0 Then
Call RecursiveFolder(oFolder, 0)
Else
If Timer < (TimeLimit * 60 + StartTime) Then Call RecursiveFolder(oFolder, TimeLimit * 60 + StartTime)
End If

FastExit:
Range("A:K") = X
If i < 65535 Then Range(Cells(i + 1, "A"), Cells(65536, "A")).EntireRow.Delete
Range("A:K").WrapText = False
Range("A:K").EntireColumn.AutoFit
Range("1:1").Font.Bold = True
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("a1").Activate

Set FSO = Nothing
Set objShell = Nothing
Set oFolder = Nothing
Set objFolder = Nothing
Set objFolderItem = Nothing
Set Fil = Nothing
Application.StatusBar = ""
Application.ScreenUpdating = True
End Sub
Newyana2
2023-03-02 03:16:06 UTC
Permalink
"Databeheer Quantore" <***@gmail.com> wrote

| How can I define a value with 'Getting File Info using GetDetailsOf'
|
What do you mean by define a value? Each number defines
a property. The properties vary by Windows version.
Databeheer Quantore
2023-03-08 13:01:10 UTC
Permalink
Post by Newyana2
| How can I define a value with 'Getting File Info using GetDetailsOf'
|
What do you mean by define a value? Each number defines
a property. The properties vary by Windows version.
I mean from the propertie owner I only want my own files. So owner =me

So perhaps I meant filtering?
Newyana2
2023-03-08 13:59:04 UTC
Permalink
"Databeheer Quantore" <***@gmail.com> wrote

| > What do you mean by define a value? Each number defines
| > a property. The properties vary by Windows version.
|
| I mean from the propertie owner I only want my own files. So owner =me
|
| So perhaps I meant filtering?

Sorry, I don't understand. Maybe if you explain what
you're actually trying to accomplish.
Databeheer Quantore
2023-03-08 15:23:20 UTC
Permalink
Post by Newyana2
| > What do you mean by define a value? Each number defines
| > a property. The properties vary by Windows version.
|
| I mean from the propertie owner I only want my own files. So owner =me
|
| So perhaps I meant filtering?
Sorry, I don't understand. Maybe if you explain what
you're actually trying to accomplish.
I want to list files by certain owner(s) to improve datamanagement.

Thanks in advance!

ps.I'm warned that I put the question in the wrong group... so further questions should be elsewhere.
Newyana2
2023-03-08 18:39:42 UTC
Permalink
"Databeheer Quantore" <***@gmail.com> wrote


| I want to list files by certain owner(s) to improve datamanagement.
|
I see. I've never run a computer with multiple users
and I always run as admin, so I wasn't familiar with this.
But it looks like you can do what you want:

https://www.vbsedit.com/scripts/security/ownership/scr_1386.asp

Basically you'd use WMI to get those file properties.
The properties you were looking at before are properties like
size, lastmodified time, etc.

Unfortunately, WMI is horrendously designed. It's all wrpapped
in a pseudo-SQL format. But it does have a great deal of
functionality.

Probably you'd want to use the FileSystemObject to
enumerate through folders, then run each file path
through the WMI check. Tedious, but not very complicated.
If you don't know about WMI you might want to get a
copy of the help file.

Ulrich Möller
2023-03-08 15:08:24 UTC
Permalink
Post by Databeheer Quantore
How can I define a value with 'Getting File Info using GetDetailsOf'
...

Hi,
you are in the wrong newsgroup.
For Excel and VBA questions you should change to an Excel newsgroup.
Databeheer Quantore
2023-03-08 15:26:42 UTC
Permalink
Post by Ulrich Möller
Post by Databeheer Quantore
How can I define a value with 'Getting File Info using GetDetailsOf'
...
Hi,
you are in the wrong newsgroup.
For Excel and VBA questions you should change to an Excel newsgroup.
Do you have a link please? Thanks in advance!!
Loading...