Results 1 to 10 of 38

Thread: TestsExplorerWSO

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #30
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    This is post
    https://www.excelfox.com/forum/showt...ll=1#post23968
    https://www.excelfox.com/forum/showthread.php/2951-TestsExplorerWSO?p=23968&viewfull=1#post23968
    https://www.excelfox.com/forum/showt...lorerWSO/page3
    https://www.excelfox.com/forum/showthread.php/2951-TestsExplorerWSO/page3#post23968

    , in support of this main forum question
    https://eileenslounge.com/viewtopic....313909#p313909




    Hi,
    Quote Originally Posted by SpeakEasy post_id=313838 time=1706548252 user_id=8741
    ...You can actually reference the extended properties by name, rather than by number. This maintains consistency if Microsoft change the numbering
    How? I have not been able to find a direct or built in way to do this yet.
    This indirect way example will work for me, but I thought I would ask in case I missed something?

    What this function does is simply loop through all the property names, as given by the first few hundred numbers, PropItmNmbr , and if it finds the name you are looking for then it gives you the corresponding number, PropItmNmbr, which you can then use in the main coding in the usual way,
    objWSOFolder.GetDetailsOf(FldItm, PropItmNmbr)

    Code:
    Sub TestItmNmbrWSOfromPropName()    '                                                     https://www.excelfox.com/forum/showthread.php/2951-TestsExplorerWSO?p=23968&viewfull=1#post23968
    ' I want the Name property value. I can get it from  GetDetailsOf(FldItm, 0)  where  FldItm  is a windows shell object (WSO) folder item whose properties I am intersted in , and, as example, the  0  is the property item number, PropItmNmbr, that I have so far seen in any operating system for the property of the file or folder  Name
     MsgBox Prompt:=ItmNmbrWSOfromPropName("Name")           ' German and English  name property
     MsgBox Prompt:=ItmNmbrWSOfromPropName("Größe")          ' German size property
     MsgBox Prompt:=ItmNmbrWSOfromPropName("Size")           ' English size property          https://eileenslounge.com/viewtopic.php?p=313847#p313847
     MsgBox Prompt:=ItmNmbrWSOfromPropName("Dateiversion")   ' German version property
     MsgBox Prompt:=ItmNmbrWSOfromPropName("File version")   ' English version property
    
    End Sub
    
    Public Function ItmNmbrWSOfromPropName(ByVal PropNme As String) As String
    Dim PropItmNmbr As Long
    'Dim objWSO As Shell32.Shell                 ' Early Binding          ' Set objShell = New Shell32.Shell             '    https://i.postimg.cc/Fz9zrnNm/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg     https://i.postimg.cc/sDC9S54h/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpgDim objWSO As Object                        ' Late Binding
    Dim objWSO As Object                        ' Late Binding
    ' Set objwso = New Shell32.Shell                                                                   '    https://i.postimg.cc/Fz9zrnNm/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg     https://i.postimg.cc/sDC9S54h/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg
     Set objWSO = CreateObject("shell.application")
    'Dim objWSOFolder As Shell32.Folder                                            : Set objWSOFolder = objWSO.Namespace(Parf)
    Dim objWSOFolder As Object: Set objWSOFolder = objWSO.Namespace(ThisWorkbook.Path & "")     '  Any valid path will do       objWSO.Namespace(Parf & "")  '   & ""               ' https://stackoverflow.com/questions/33868233/shell-namespace-not-accepting-string-variable-but-accepting-string-itself/77888851#77888851     https://microsoft.public.access.narkive.com/Jl55mts5/problem-using-shell-namespace-method-in-vba#post5
    'Dim FldItm As Shell32.FolderItem
        For PropItmNmbr = 0 To 400 Step 1
            'If objWSOFolder.GetDetailsOf("You can put anything here.  Null  is fashionable, but anything will do, as long as it is not a valid WSO folder item object - see https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg.9xhyRrsUUOM9zYlZPKdOpm", PropItmNmbr) = PropNme Then
            If objWSOFolder.GetDetailsOf(Null, PropItmNmbr) = PropNme Then
             Let ItmNmbrWSOfromPropName = PropItmNmbr   '  Effectively fill the pseudo String variable  ItmNmbrWSOfromPropName  with the number you were looking for
             Exit Function
            Else
            End If
        Next PropItmNmbr
     Let ItmNmbrWSOfromPropName = "Couldn't find the WSO property item number for a property with the name of    " & PropNme    '   '  Effectively fill the pseudo String variable  ItmNmbrWSOfromPropName  with a message if the WSO property name you gave could not be found for any og the numbers you looped  ( 0 to 400 )
    End Function
    I don’t need super speed performance, so that solution would do. But I was thinking there might be some direct way with some existing method or similar which I have not been able to find yet, like pseudo something like this sort of form
    objWSOFolder.GetDetailsOf(FldItm, "Name")




    ' This next function adds the possibility of multiple name attempts for example if you have the property name in different language, (and if you know of different names within the same language!!). You can give a single name or several names which should be separated by a comma, a semi colon, or any number or spaces more than one, or a combination of spaces and a comma or a semi colon
    Code:
     Sub TestItmNmbrWSOfromPropNameS()    '                                                     https://www.excelfox.com/forum/showthread.php/2951-TestsExplorerWSO?p=23968&viewfull=1#post23968
    ' I want the Name property value. I can get it from  GetDetailsOf(FldItm, 0)  where  FldItm  is a windows shell object (WSO) folder item whose properties I am intersted in , and, as example, the  0  is the property item number, PropItmNmbr, that I have so far seen in any operating system for the property of the file or folder  Name
     Debug.Print "Name    "; Tab(25); ItmNmbrWSOfromPropNameS("Name")           ' German and English  name property
     Debug.Print "Size     "; Tab(25); ItmNmbrWSOfromPropNameS("Größe, Size")     ' German and English size property
     Debug.Print "Version     "; Tab(25); ItmNmbrWSOfromPropNameS("Dateiversion;File version")     ' German and English version property
     Debug.Print "Last modified date    "; Tab(25); ItmNmbrWSOfromPropNameS("Geändert am, Date modified; Änderungsdatum")     ' German and English date last modified property
     Debug.Print "Created date    "; Tab(25); ItmNmbrWSOfromPropNameS("Date created, Erstellt am, Erstelldatum")     ' German and English datee created  property
    End Sub
    
    ' The next function adds the possibility of multiple name attempts for example if you have the property name in different languages. You can give a single name or several names which should be separated by a comma, a semi colon, or any number or spaces or a combination of spaces and a comma or a semi colon
    ' The function returns the property number and the name found, if successful
    Public Function ItmNmbrWSOfromPropNameS(ByVal PropNme As String) As String
     Let PropNme = Trim(PropNme)  '     VBA Trim remove just leading and trailing sppaces
    ' Let PropNme = Replace(PropNme, " ", "  ", 1, -1, vbBinaryCompare)
     Let PropNme = Replace(PropNme, ";", "  ", 1, -1, vbBinaryCompare)
     Let PropNme = Replace(PropNme, ",", "  ", 1, -1, vbBinaryCompare)
    ' Let PropNme = Application.Trim(PropNme)  '  Remove all leading and trailing spaces, and all spaces more than one in between
     Let PropNme = Replace(PropNme, "      ", "  ", 1, -1, vbBinaryCompare)  '  6 spaces to 2 spaces
     Let PropNme = Replace(PropNme, "     ", "  ", 1, -1, vbBinaryCompare)  '  5 spaces to 2 spaces
     Let PropNme = Replace(PropNme, "    ", "  ", 1, -1, vbBinaryCompare)  '  4 spaces to 2 spaces
     Let PropNme = Replace(PropNme, "   ", "  ", 1, -1, vbBinaryCompare)  '  3 spaces to 2 spaces
    Dim arrNms() As String: Let arrNms() = Split(PropNme, "  ", -1, vbBinaryCompare)
    Dim PropItmNmbr As Long
    'Dim objWSO As Shell32.Shell                 ' Early Binding          ' Set objShell = New Shell32.Shell             '    https://i.postimg.cc/Fz9zrnNm/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg     https://i.postimg.cc/sDC9S54h/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpgDim objWSO As Object                        ' Late Binding
    Dim objWSO As Object                        ' Late Binding
    ' Set objwso = New Shell32.Shell                                                                   '    https://i.postimg.cc/Fz9zrnNm/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg     https://i.postimg.cc/sDC9S54h/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg
     Set objWSO = CreateObject("shell.application")
    'Dim objWSOFolder As Shell32.Folder                                            : Set objWSOFolder = objWSO.Namespace(Parf)
    Dim objWSOFolder As Object: Set objWSOFolder = objWSO.Namespace(ThisWorkbook.Path & "")     '  Any valid path will do       objWSO.Namespace(Parf & "")  '   & ""               ' https://stackoverflow.com/questions/33868233/shell-namespace-not-accepting-string-variable-but-accepting-string-itself/77888851#77888851     https://microsoft.public.access.narkive.com/Jl55mts5/problem-using-shell-namespace-method-in-vba#post5
    'Dim FldItm As Shell32.FolderItem
        For PropItmNmbr = 0 To 400 Step 1
        Dim Cnt As Long
            For Cnt = LBound(arrNms()) To UBound(arrNms())
                'If objWSOFolder.GetDetailsOf("You can put anything here.  Null  is fashionable, but anything will do, as long as it is not a valid WSO folder item object - see https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg.9xhyRrsUUOM9zYlZPKdOpm", PropItmNmbr) = PropNme Then
                If objWSOFolder.GetDetailsOf(Null, PropItmNmbr) = arrNms(Cnt) Then
                 Let ItmNmbrWSOfromPropNameS = PropItmNmbr & " " & arrNms(Cnt)  '  Effectively fill the pseudo String variable  ItmNmbrWSOfromPropName  with the number you were looking for
                 Exit Function
                Else
                End If
            Next Cnt
        Next PropItmNmbr
     Let ItmNmbrWSOfromPropNameS = "Couldn't find the WSO property item number for a property with the name of    " & PropNme    '   '  Effectively fill the pseudo String variable  ItmNmbrWSOfromPropName  with a message if the WSO property name you gave could not be found for any of the numbers you looped  ( 0 to 400 )
    End Function



    ' The function returns the property number and the name found, if successful, for example using the test macro we get in German windows 10
    Code:
     Name                    0 Name
    Size                    1 Größe
    Version                 166 Dateiversion
    Last modified date      3 Änderungsdatum
    Created date            4 Erstelldatum
    Last edited by DocAElstein; 02-03-2024 at 09:38 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •