Windows 10 Retrieving Extended File Properties (1 Viewer)

Mohsin Malik

Registered User.
Local time
Today, 04:04
Joined
Mar 25, 2012
Messages
179
Hi,

I have used GetDetailsOf method to retrieve extended file properties to read Comments (objFolder.GetDetailsOf(strFileName, 24), Title (objFolder.GetDetailsOf(strFileName, 10) and Category objFolder.GetDetailsOf(strFileName, 12). This was working before and I have noticed that it is not working in Windows10. Can anyone advise what is wrong and if I can read these 03 extended file properties?

Thank you
Mohsin
 
see these links for info and example
http://www.everythingaccess.com/tut...-information-provided-by-the-Operating-System and
http://www.accessmvp.com/Strive4Peace/DB_ListFiles.htm


If you have details on your GetDetailsOf method of some class, then please show same to readers.

Update: I found these links after posting:
http://www.utteraccess.com/forum/lofiversion/index.php/t2032956.html
http://p2p.wrox.com/excel-vba/35766-file-information.html

Note the sample code at the wrox link is using excel constructs in the vba, but could be adapted for Access.

Good luck.
 
Last edited:
Updated to improve efficiency, May 2018. (Been meaning to do that for a year. It's more than twice as fast as it was.)

GetDetailsOf didn't change — your folder did! The attributes available to the GetDetailsOf method vary depending on the folder in which it is displayed.

While Comments, Title and Category may been in locations 24, 10 and 12 on your previous system, that is no indication of a "permanent" column, and different attributes are available for different filetypes.

It would be better to find the attributes and their values by looping through all available attributes, perhaps like this:

Code:
Sub GetFileAttributes()
    '(May 2018: updated to improve efficiency)
    'Requires reference: "Microsoft Shell Controls and Automation" (shell332.dll)
    Const strFilePath = "c:\MP3's\Beastie Boys - Intergalactic.mp3"
    
    Dim objShell As Shell, objFolder As Folder, objFolderItem As FolderItem
    Dim props As Object, i As Long, strPath As String, strFile As String
    
    strFile = Mid(strFilePath, InStrRev(strFilePath, "\") + 1) 'extract filename
    strPath = Left(strFilePath, Len(strFilePath) - Len(strFile) - 1) 'extract path
    
    Set objShell = New Shell
    Set objFolder = objShell.NameSpace(strPath) 'create folder object
    Set objFolderItem = objFolder.ParseName(strFile) 'create file object
    Set props = CreateObject("Scripting.Dictionary") 'create dictionary object

    For i = 0 To 286 'put properties in dictionary object for eacy retrieval later
        props.Add objFolder.GetDetailsOf(objFolder.Items, i), objFolder.GetDetailsOf(objFolderItem, i)
    Next i

    'dictionary is populated. Now list properties that have values
    Dim key As Variant
    For Each key In props.Keys 'enumerate dictionary
        If props(key) <> "" Then Debug.Print key & ": " & props(key)
    Next key
    'or, return specific property:  If props.Exists("Category") Then Debug.Print props("Category")
    
    props.RemoveAll ' clean up
    Set objFolderItem = Nothing
    Set objFolder = Nothing
    Set objShell = Nothing
End Sub
Attribute Names come from the folder.
Attribute Values comes from the file.

Full description of GetDetailsOf : http://msdn.microsoft.com/en-us/library/windows/desktop/bb787870(v=vs.85).aspx
 
Last edited:
If it worked before but not now, I suspect its a missing reference rather than an issue with Windows 10

I'd never heard of GetDetailsOf and couldn't find it listed in the VBE.
However it was listed when I added the reference 'Microsoft Shell Controls and Automation'

Skim reading various links from a Google search including the wrox.com link supplied in jdraw's post confirmed the need for that reference

When you've got it working, please supply example code so we can all benefit.

If you can't get it working, there are other ways of getting file attributes.
For example FileDateTime(filename) - returns a Variant (Date) that indicates the date and time when a file was created or last modified.

EDIT: just read @ashleedawg's reply and a similar comment online:

While Comments, Title and Category may been in locations 24, 10 and 12 on your previous system, that is no indication of a "permanent" column, and different attributes are available for different filetypes.

Perhaps this method has similar disadvantages to SendKeys - what works in one version has to be updated for another version
 
Last edited:
It may be that other forum users are very familiar with this but I wasn't...
If what follows is old news to everyone else, my apologies (but see my new byline)

I've just been playing with the function supplied by @ashleedawg in post #3 for a variety of file types e.g. docx / gif / pdf / accdb / mp3 / csv

Obviously the properties obtained vary for each.
I've made minor changes to that code so it only prints out properties which have a value.

The full list has 256 properties - see attached text file

Code:
'This requires the reference: Microsoft Shell Controls and Automation

Sub GetFileAttributes()

'enter the full path to the file
   ' Const strFilePath = "G:\Programs\MendipDataSystems\CommonFiles\SDA\Icons\SDA_DEMO.ico"
   ' Const strFilePath = "G:\Programs\MendipDataSystems\CommonFiles\SDA\Images\AccessErrorCodes.gif"
   ' Const strFilePath = "G:\Programs\MendipDataSystems\CommonFiles\SDA\Documentation\AnalyseSessionReportGrades.pdf"
    Const strFilePath = "D:\Colin\My Documents\My Music\Leonard Cohen\You Want It Darker\04 Leaving The Table.mp3"
    
    Dim objShell As Shell32.Shell
    Dim objFolder As Shell32.Folder
    Dim objFolderItem As Shell32.FolderItem
    Dim strPath As String, strFileName As String
    Dim aName As String, aValue As String
    Dim I As Integer
    Dim tComments As String, tCategory As String, tTitle As String
    
    I = 1
    strFileName = strFilePath
    Do Until I = 0 'find the last "\" and get the filename
        I = InStr(1, strFileName, "\", vbBinaryCompare)
        strFileName = Mid(strFileName, I + 1)
    Loop
    strPath = Left(strFilePath, Len(strFilePath) - Len(strFileName) - 1)
    Set objShell = New Shell
    Set objFolder = objShell.NameSpace(strPath)
    Set objFolderItem = objFolder.ParseName(strFileName)
        
    For I = 0 To 255
        aName = objFolder.GetDetailsOf(objFolder.Items, I)
        aValue = objFolder.GetDetailsOf(objFolderItem, I)
        
        'list attributes available in this folder:
        If Nz(objFolder.GetDetailsOf(objFolderItem, I), "") <> "" Then
            Debug.Print I & " - " & objFolder.GetDetailsOf(objFolder.Items, I) & ": " & _
                  objFolder.GetDetailsOf(objFolderItem, I)
        End If
        
    Next I
    
    Set objFolderItem = Nothing
    Set objFolder = Nothing
    Set objShell = Nothing
     

End Sub

Its extremely fast & potentially very useful in that it gets lots of properties at once that previously I had to obtain in a variety of ways.
For example, file size / date created / modified / image dimensions etc etc

Unfortunately for a csv file it didn't give the total number of records / rows but I can do that in other ways.

As an example, this is the output for an image file:

0 - Name: AccessErrorCodes.gif
1 - Size: 27.1 KB
2 - Item type: GIF File
3 - Date modified: 14/11/2015 00:01
4 - Date created: 14/11/2015 00:01
5 - Date accessed: 14/11/2015 00:01
6 - Attributes: A
8 - Availability: Available offline
9 - Perceived type: Image
10 - Owner: S-1-5-21-2930312881-120557777-2257318752-3500
11 - Kind: Picture
19 - Rating: Unrated
31 - Dimensions: ?400 x 331?
50 - Total size: 472 GB
54 - Computer: COLIN-PC (this PC)
157 - File extension: .gif
158 - Filename: AccessErrorCodes.gif
162 - Space free: 359 GB
167 - Bit depth: 8
168 - Horizontal resolution: ?96 dpi
169 - Width: ?400 pixels
170 - Vertical resolution: ?96 dpi
171 - Height: ?331 pixels
180 - Shared: No
183 - Folder name: Images
184 - Folder path: G:\Programs\MendipDataSystems\CommonFiles\SDA\Images
185 - Folder: Images (G:\Programs\MendipDataSystems\CommonFiles\SDA)
187 - Path: G:\Programs\MendipDataSystems\CommonFiles\SDA\Images\AccessErrorCodes.gif
189 - Type: GIF File
195 - Link status: Unresolved
247 - Space used: ?23%

Time taken < 1 second
Other file types may take slightly longer e.g. mp3

Later I'm going to try taking this a stage further to loop through all the files in a folder and saving the attributes to a log file / spreadsheet or Access table.

Before I spend any time doing so, if anyone already has code for this, please let me know
 

Attachments

Last edited:
Colin,
I don't have such, but I think it is a worthwhile effort and could be useful in the samples area.

Even to show what attributes are available for certain file types would be a useful reference .

Keep us updated.
 
I've just added a text file with a full list of file attributes that are available using this function - see post #5
 
Last edited:
Hello,

Thanks for providing example code. I am using Colin @ridders code provided in post # 5 and tested on 02 different computers running Windows 10 and Office2016. All I need is to get Comments/Title/Tags property for any XLSM file. I have noticed that GetDetailsOf method stopped getting extended properties on 01 computer, I have recorded screens where you can see the reference is set to Shell32.dll and I am unsure what has caused this issue of missing attributes in few computers which was working previously?

###I am getting following attributes on Computer#1
Preview
0 - Name: Collect Data-DarwinCabr-20170531-3.xlsm
1 - Size: 1.27 MB
2 - Item type: Microsoft Excel Macro-Enabled Worksheet
3 - Date modified: 6/20/2017 8:25 PM
4 - Date created: 6/4/2017 3:38 PM
5 - Date accessed: 6/20/2017 8:25 PM
6 - Attributes: A


###I have run the same code and getting following attributes on Computer # 2

Preview
0 - Name: Collect Data & Send Emails-DarwinCabr-20170531-2.xlsm
1 - Size: 1.22 MB
2 - Item type: Microsoft Excel Macro-Enabled Worksheet
3 - Date modified: 6/3/2017 12:06 PM
4 - Date created: 5/31/2017 9:39 AM
5 - Date accessed: 6/24/2017 11:37 PM
6 - Attributes: A
8 - Availability: Available offline
9 - Perceived type: Document
10 - Owner: RIZWAN\EXPERTS-PC
11 - Kind: Document
18 - Tags: read
19 - Rating: Unrated
20 - Authors: ABC Work
21 - Title: Collect Data & Send Emails;3050;Chevron Central America;Darwin Cabrera;email123@gmail.com;1477;816
23 - Categories: 68; 60; 2; 6; 0; 0; 0; 0; 0; 0; 0.514; 0; 0; 60; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 6; 0; 0; 0; 0; 0; 0
24 - Comments: Send Task: 5/31/2017 12:38:56 AM; Read:1/06/2017 21:34:02
33 - Company: ABC Work
35 - Program name: Microsoft Excel
50 - Total size: 293 GB
53 - Computer: RIZWAN (this PC)
144 - Content created: ?1/?11/?2008 ??5:30 PM
146 - Date last saved: ?6/?3/?2017 ??12:06 PM
156 - File extension: .xlsm
157 - Filename: Collect Data & Send Emails-DarwinCabr-20170531-2.xlsm
161 - Space free: 203 GB
178 - Shared: No
181 - Folder name: Downloads
182 - Folder path: C:\Users\EXPERTS-PC\Downloads
183 - Folder: Downloads (C:\Users\EXPERTS-PC)
185 - Path: C:\Users\EXPERTS-PC\Downloads\Collect Data & Send Emails-DarwinCabr-20170531-2.xlsm
187 - Type: Microsoft Excel Macro-Enabled Worksheet
193 - Link status: Unresolved
242 - Space used: ?30%

Awaiting instructions.

Thank you
Mohsin
 
Last edited:
I don't think there is a limit to the number of attributes, just a maximum of 255 per file. There can't be of "all" attributes since anyone could can make up custom attributes, like a Name:value pair.
 
Last edited:
As I said this has stopped working recently and I will appreciate if there will be any directions to troubleshoot/fix this?
 
Just for snorts & giggles, find the corresponding files on the two computers. For each, right-click the file, then click for Properties, then Details. See if they are the same on the two computers when you use the file system rather than VBA to look at the details.

I also notice that your dump of the attributes doesn't match in file size or name. Are those supposed to be the same files? If so, how did the file get to the 2nd computer? Some network copy operations aren't able to copy attributes correctly.
 
Just for snorts & giggles, find the corresponding files on the two computers. For each, right-click the file, then click for Properties, then Details. See if they are the same on the two computers when you use the file system rather than VBA to look at the details.

I also notice that your dump of the attributes doesn't match in file size or name. Are those supposed to be the same files? If so, how did the file get to the 2nd computer? Some network copy operations aren't able to copy attributes correctly.

Hi The Doc Man, Difference in file name is because we have hundreds of XLSM files where we are reading tags and other properties on daily basis. All of my XLSM files have the same attributes as it were before. I am afraid if recent Windows10 update has caused this issue on computers?

Here is the screenshot of file details preview that stopped retrieving on some of computers.
yekM8L
 

Attachments

  • FileDetails.png
    FileDetails.png
    22.7 KB · Views: 474
Going to try & reply to all in one go...
Apologies if I miss anyone out.

@Mohsin Malik
The reason I said 'from whom exactly' was that I've never even heard of GetDetailsOf function before today. You've used it before!

The issue is with your computers rather than the code supplied (courtesy of @ashleedawg)

Only you can really investigate the difference between your 2 computers.
As @Doc Man pointed out you aren't actually comparing like with like.

======================================

@ashleedawg
I may be wrong (& I often am) but it seems to me that the attributes that GetDetailsOf extracts are built into this member of the Shell32 library.

Although a user could create a new attribute "Foo" with a value "Fighters" (I'm watching Glastonbury - on TV - as I'm an old fart), would the library be able to pull that combination?

If it could, that would be coders Nirvana (sorry!)

======================================
@jdraw
I've just completed the first draft of code to get file attributes for all files in a folder. First attempt went as follows (on a slow computer):
Images: approx 950 GIF files ; 130 sec
Photos: approx 3700 BMP files ; 8min 30sec
Documents: approx 70 PDF files ; <1 sec!

Going to try mixture of PDF / DOCX files next in a folder / subfolder combination. May be a bit more tricky ...

Still a way to go before its suitable for general use by others but it looks promising.
Hopefully I can optimise the code to make it faster.
 
Last edited:
Final update from me on this for tonight.
On re-testing, it seems there are 311 attributes - 0 to 310

The extras are largely to do with photo/video properties

Modified code:

Code:
Public Sub GetFileAttributes(strFilePath As String)

Dim strProc As String, I as Integer

strProc = "GetFileAttributes"

'This requires the reference: Microsoft Shell Controls and Automation
   
 On Error GoTo Err_Handler
    
    I = 1
    strFileName = strFilePath
    Do Until I = 0 'find the last "\" and get the filename
        I = InStr(1, strFileName, "\", vbBinaryCompare)
        strFileName = Mid(strFileName, I + 1)
    Loop
    
    strPath = Left(strFilePath, Len(strFilePath) - Len(strFileName) - 1)
    
    Set objShell = New Shell
    Set objFolder = objShell.NameSpace(strPath)
    Set objFolderItem = objFolder.ParseName(strFileName)
        
    For I = 0 To 320
        aName = objFolder.GetDetailsOf(objFolder.Items, I)
        aValue = objFolder.GetDetailsOf(objFolderItem, I)
       
       'full list of available attributes (depending on file type)
       Debug.Print I & " - " & objFolder.GetDetailsOf(objFolder.Items, I)
        
        'list attributes available in this folder:
        If Nz(objFolder.GetDetailsOf(objFolderItem, I), "") <> "" Then
            Debug.Print I & " - " & objFolder.GetDetailsOf(objFolder.Items, I) & ": " & _
                  objFolder.GetDetailsOf(objFolderItem, I)
        End If        
   
    Next I
    
    Set objFolderItem = Nothing
    Set objFolder = Nothing
    Set objShell = Nothing
        
   
Exit_Handler:
    Exit Sub
    
Err_Handler:
    MsgBox "Error " & Err.Number & " in " & strProc & " procedure: " & Err.Description
    GoTo Exit_Handler

End Sub

Typical usage:
Code:
strFilePath = "G:\Programs\MendipDataSystems\CommonFiles\SDA\Images\AccessErrorCodes.gif"
GetFileAttributes strFileName

Updated attribute list attached:
 

Attachments

The file headers of Windows NTFS files are extensible so that you can add testable file attributes. What happens is if you have a file header that is bigger than one NTFS file record (= 1kb), you get extension records (extra MSFT records) appended to a list as an external part of the header, with extra records added until you run out of addenda.

http://ntfs.com/ntfs-files-types.htm

HOWEVER, not all file transfer methods can support extended headers.

For example (and I'm certainly not saying this is specifically the culprit), if you transfer a file using FTP or SFTP, the implied protocols are all about file content but not so much about file header metadata. Doing a file copy from a shared file server via drag-n-drop ought to preserve attributes, but doing it via FTP, SFTP, SCP, HTTP, or HTTPS might not fully preserve the extension headers where those attributes are kept.

This idea and the previous elements of the thread lead me to some questions.

1. You say you think this started happening after a recent Win10 patch. Were other Win10s on your affected in the same way? Because Win10 is bloody relentless about patching when it wants you to patch it. The Win10 paradigm is to patch NOW and don't wait for permission. If it WAS a Win10 patch, every Win10 at your site should exhibit the same behavior. If they don't, then a Win10 patch isn't necessarily your culprit.

Your original comments made me think it was happening only on one computer, but subsequent comments have made me less sure of that inference. So please clarify the circumstances of how, when, and under what O/S you noticed this problem.

2. For the files that you are comparing, how did each file get where it is now? Was it created in situ or was it copied to that location? If copied, how?

3. If the files are created locally for each system, i.e. NOT copied, is there a chance that the program creating the files (Excel, it appears) might have been patched? We are looking for the reason this occurs. I'm not at all defending Win10. (BWA-HA-HA... sorry, hysterical laughter at the thought of ME defending Win10.) But to solve the problem we have to eliminate possible causes that might have occurred at the same time as the Win10 patches you suspect to be the culprits.

One thing you can do that we CAN'T do is this: Get on the machine with this problem. Do a program Start >> Windows Update - but instead of telling it to update, find the link that lets you review the patches. You should see a list that references one or more KB articles. There will be dates associated with them. You know about when this problem started so look for the patches just before that date.

For each patch in the right time frame, do a web search for a description of the KBnnnnn item associated with the patch. Read its description. If any patch is dinking around with the file system, the description should tell you SOMETHING about it.

There is one more thing to consider and it is a long shot. You MIGHT be running into a permissions problem, though I don't know if it would be this extensive. There is a detailed permission called "Read Attributes" and another one called "Read Extended Attributes." It is possible for you to be able to read "ordinary" attributes but not the "Extended" attributes (implying the ones that require external MSFT blocks).

The only reason I suggest this is because the test is non-invasive, non-destructive, and relatively fast if a bit tedious.

To test this, select a file that exhibits your problem.
* Right-click it.
* Select Security.
* From the bottom of that dialog box, select Advanced.
* From there, select Effective Permissions.
* Click Select (next to the long text box). (It is asking for a Windows user or group name in this slot.)
* In the larger box at the bottom, you can put in your login name
* Click "Check Names" to see if you are in the list. If you are, it will resolve your name to a string that names your computer and possibly your domain, depending on your exact environment.
* If you are in the list, you can click OK and see YOUR permissions.

If for some reason on the miscreant machine you don't have Read Extended Attributes, that could be your problem, though why MS would block reading of extended file attributes on a single machine is beyond me. If you have Modify or Full Control (as the high-level access names), you SHOULD be OK because "Read Extended Attributes" is implied by the high-level permission classes I named, but I try to not make assumptions.
 
Last edited:
I also exhibit the same symptoms. I am running a macro in Excel which gets the Comments property from another Excel spreadsheet. I use the same method GetObjectOf and it suddenly stopped working on one computer but not the other.

I suspect it was due to a Microsoft update as there has been nothing else that has changed on the computers. I have not updated Excel. Both computers run Windows 10 Home edition. One computer has build 14393.447 and this is working fine. The other has build 14393.1358 and it no longer works.

I ended up implementing a workaround where I have to open the other Excel file and get the Comments property using workBook.BuiltinDocumentProperties

You should compare the build versions in your 2 computers. If this differs, then it is likely a Windows update issue.
 
Hi @Doc_Man,

Thanks, I have checked the following Windows Update on 02 of my PC from June-2017 that are having this issue, https://support.microsoft.com/en-us/kb/4022715, Is this related? I have tried to uninstall this update and it is still not working? I think that Windows 10 updated Shell32.dll in recent update and it caused issue, any workaround to fix this issue? Is there a way to manually update Shell32.dll from working Windows10 computer or any way to reference Shell32.dll to some other folders (i-e D:\DLL\Shell32.dll)?

  • Addressed additional issues with updated time zone information, storage file system, Windows Update logs, USB, Start menu and taskbar and Windows Shell.
  • Security updates to Microsoft Uniscribe, Windows kernel, Windows kernel-mode drivers, Microsoft Graphics Component, Internet Explorer, Windows Shell, Microsoft Windows PDF, Device Guard and Microsoft Edge. For more information about the security vulnerabilities resolved, please refer to the Security Update Guide.

One thing you can do that we CAN'T do is this: Get on the machine with this problem. Do a program Start >> Windows Update - but instead of telling it to update, find the link that lets you review the patches. You should see a list that references one or more KB articles. There will be dates associated with them. You know about when this problem started so look for the patches just before that date.

For each patch in the right time frame, do a web search for a description of the KBnnnnn item associated with the patch. Read its description. If any patch is dinking around with the file system, the description should tell you SOMETHING about it.
 
I ended up implementing a workaround where I have to open the other Excel file and get the Comments property using workBook.BuiltinDocumentProperties

This is comparatively a slower approach when you loop through number of directories and open each excel file to read BuiltinDocumentProperties.
 

Users who are viewing this thread

Back
Top Bottom