Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 38

Thread: TestsExplorerWSO

  1. #21
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    Some screen shots for this post https://eileenslounge.com/viewtopic....313792#p313792











    ......Here a slightly simpler demo, just for Eileens Lounge..., but it’s a real example looking at one of the smaller Folders I have been wanting to investigate.
    To do it:
    Put the uploaded file, EileenMMDemo.xls, and this folder ,
    Movie Maker https://app.box.com/s/cxvc735a85q6az2r3gtb7ii9w2p3jzpf
    , in the same place. Then just open the file EileenMMDemo.xls. That file only has one worksheet so the workbook should show just one window of that. In that window make a selection towards the left. Now run the only available macro, Sub PassFolderForReocursing3() , in that workbook which is in the only code module. At the start of the macro it will use the ActiveCell of that window to try and get a single cell range object from the your window Selection . It usually manages that, and goes on to put some results out with that cell at top left. It should look something like this
    Attached Files Attached Files

  2. #22
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    Here is the main recursion / reoccurring macro 3 corrected slightly for to get the Late Binding working correctly

    A couple of things were wrong, or rather one thing wrong, which hid a another problem that should have occurred: I had a few things not declared as objects as they should have been. As I coincidently still had the two library references checked, all still worked, and so did a string variable in this bit Set objWSOFolder = objWSO.Namespace(Pf)
    Taking the references off, revealed the problem. Once that was fixed the other problem cropped up https://stackoverflow.com/questions/...88851#77888851
    https://microsoft.public.access.nark...d-in-vba#post5


    This next coding is OK, I think

    Code:
    Option Explicit
    '  "Global" variables that must be declared here
    Dim Clm As Long, Reocopy As Long ' variable for column number to put file or folder details in, number representing the copy of the second macro running at any time
    '  Variables useful/ efficient to declare here as "Global" variables
    '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.jpg
    Dim objWSO As Object                        ' Late Binding
    'Dim objFSO As Scripting.FileSystemObject    ' Early Binding          ' Set objFSO = New Scripting.FileSystemObject  ' https://i.postimg.cc/d1GHPGxJ/Microsoft-Scripting-Runtime-Library.jpg
    Dim objFSO As Object                        ' Late Binding
    Dim MeActiveCell As Range                   ' For convenience all output will be referred to a start point. The user should make a selection in the workbook window that has the worksheet for output showing in it.  We will then be able to get the ramge object into VBA from the  ActiveCell  property of that workbook window
    Sub PassFolderForReocursing3()  '
    Rem 0
     Let Clm = 1: Reocopy = 0                                         ' When this macro starts we have not started any output so our column number for output should not yet have been set, and no copies of the next macro will be running so the variable keeping track of the copy number of that macro should not have a number >= 1
    Rem 1
    Dim Ws As Worksheet: Set Ws = Me                                  ' This is and the next bits are a personal preferrence. I like to fully explicitly tell VBA where things are, and I also have a habit of putting coding intended for a worksheet in that particular worksheets code module. Many people work on whatever worksheet is active, so they may prefer to change this to   Set Ws = Application.ActiveSheet, and use that in the next bit.
    Me.Activate: Set MeActiveCell = Workbooks(Me.Parent.Name).Windows.Item(1).ActiveCell ' https://eileenslounge.com/viewtopic.php?p=313747#p313747
    ' 1b
    Dim Parf As String:  Let Parf = ThisWorkbook.Path                 ' This should be given the path to the folder where the folder of interest is, so theere is a good chance this will need to be changed to suit quit often.
    ' 1c  A short string part of the path put top left, not necerssary but just useful for later referrence to give indication of where the main folder was got from
        If Len(Parf) - Len(Replace(Parf, "\", "", 1, -1, vbBinaryCompare)) >= 2 Then ' For a longer path it may be convenient to shorten the output given to the last bit
         Let MeActiveCell = Mid(Parf, InStrRev(Parf, "\", InStrRev(Parf, "\", -1, vbBinaryCompare) - 1, vbBinaryCompare))
        Else ' For a shorter path we can give the full path
         Let MeActiveCell = Parf
        End If
    Rem 2  Windows Shell object
    ' 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(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
    
    Rem 3 Movie Maker Folder Property names and Property values.
    'Dim FldItm As Shell32.FolderItem
    Dim FldItm As Object
        For Each FldItm In objWSOFolder.Items  '  We loop through all items to find the Movie Maker folder ' =======
            If FldItm.Name = "Movie Maker" Then
            Dim Rw As Long: Let Rw = 1
            ' Property   Name of file or folder
             Let MeActiveCell.Offset(Rw, 0) = objWSOFolder.GetDetailsOf("Willy", 0)
             Let MeActiveCell.Offset(Rw, Clm) = objWSOFolder.GetDetailsOf(FldItm, 0)       '   Name of folder or file  using the WSO way
            ' Property   File or folder size. I use the FSO for this to get a better precision and also because it seems to be broken for a folder item in WSO
             Let MeActiveCell.Offset(Rw + 1, 0) = objWSOFolder.GetDetailsOf("Wonka", 1)
                If objWSOFolder.GetDetailsOf(FldItm, 2) = "Dateiordner" Then                '   GetDetailsOf(FldItm, 2)   tells me the type of the WSO item
                'Set objFSO = New Scripting.FileSystemObject     ' https://i.postimg.cc/d1GHPGxJ/Microsoft-Scripting-Runtime-Library.jpg
                Set objFSO = CreateObject("Scripting.FileSystemObject")
                'Dim objFSOFolder As Scripting.Folder: Set objFSOFolder = objFSO.GetFolder(ThisWorkbook.Path & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
                Dim objFSOFolder As Object: Set objFSOFolder = objFSO.GetFolder(ThisWorkbook.Path & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
                 Let MeActiveCell.Offset(Rw + 1, Clm) = objFSOFolder.Size
                Else ' If the item is not a folder, then I assume it will be a file?
                'Dim ObjFSOFile As Scripting.File: Set ObjFSOFile = objFSO.GetFile(ThisWorkbook.Path & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
                Dim ObjFSOFile As Object: Set ObjFSOFile = objFSO.GetFile(ThisWorkbook.Path & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
                 Let MeActiveCell.Offset(Rw + 1, Clm) = ObjFSOFile.Size
                End If
             ' Property   Date Last Modified   Änderungsdatum
              Let MeActiveCell.Offset(Rw + 2, 0) = objWSOFolder.GetDetailsOf(42, 3)
              Let MeActiveCell.Offset(Rw + 2, Clm) = Format(objWSOFolder.GetDetailsOf(FldItm, 3), "dd,mmm,yy")
             ' Property   Date Created         Erstelldatum
              Let MeActiveCell.Offset(Rw + 3, 0) = objWSOFolder.GetDetailsOf(42, 4)
              Let MeActiveCell.Offset(Rw + 3, Clm) = Format(objWSOFolder.GetDetailsOf(FldItm, 4), "dd,mmm,yy")
             ' Property   Version
              Let MeActiveCell.Offset(Rw + 4, Clm) = objWSOFolder.GetDetailsOf(666, 166)
              Let MeActiveCell.Offset(Rw + 4, Clm) = objWSOFolder.GetDetailsOf(FldItm, 166)
             Rem 4
             Let Clm = 0
             MeActiveCell.Offset(0, 2).Select: Set MeActiveCell = Workbooks(Me.Parent.Name).Windows.Item(1).ActiveCell ' https://eileenslounge.com/viewtopic.php?p=313747#p313747
             ' 4b
             Call ReoccurringFldItmeFolderProps3(Parf & "\Movie Maker")
             Exit For ' Once we have passed on the full path of the folder,  Movie Maker  , then we are finished with this macro, so we don't need loop further looking fot the Movie Maker folder
            Else
            End If
        Next FldItm ' ===========================================================================================
    End Sub
    Recursion / Reoccring part in next post

  3. #23
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    Code:
    Private Sub ReoccurringFldItmeFolderProps3(ByVal Pf As String)
    Rem 0
     Let Reocopy = Reocopy + 1 ' Originally the variable  Reocopy  is zero.  It will become 1 on first entering the macro.  Every time we leave this macro, this number is reduced by 1   So in simple use it will be 1 or zero indicating that a copy is in use.  However, should this macro "Call itself", before its finished , ( the recursion idea ) then the value will be 2  and so on.  So effectively it tells us which copy is running at any time
    Rem 1
     '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((Pf))  '
    Dim objWSOFolder As Object: Set objWSOFolder = objWSO.Namespace((Pf))  '  (( ))  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
    Rem 2
    'Dim FldItm As Shell32.FolderItem
    Dim FldItm As Object
        For Each FldItm In objWSOFolder.Items ' ======= Main Loop ==================================================|
        ' Dim Clm As Long: ' Global variable
         Let Clm = Clm + 1
        Dim Rw As Long: Let Rw = Reocopy + 1
             Let MeActiveCell.Offset(Rw, Clm) = objWSOFolder.GetDetailsOf(FldItm, 0)
                If objWSOFolder.GetDetailsOf(FldItm, 2) = "Dateiordner" Then                '   GetDetailsOf(FldItm, 2)   tells me the type of the WSO item
                'Set objFSO = New Scripting.FileSystemObject     ' https://i.postimg.cc/d1GHPGxJ/Microsoft-Scripting-Runtime-Library.jpg
                Set objFSO = CreateObject("Scripting.FileSystemObject")
                'Dim objFSOFolder As Scripting.Folder: Set objFSOFolder = objFSO.GetFolder(Pf & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
                Dim objFSOFolder As Object: Set objFSOFolder = objFSO.GetFolder(Pf & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
                 Let MeActiveCell.Offset(Rw + 1, Clm) = objFSOFolder.Size
                Else ' If the item is not a folder, then I assume it will be a file?
                'Dim ObjFSOFile As Scripting.File: Set ObjFSOFile = objFSO.GetFile(Pf & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
                Dim ObjFSOFile As Object: Set ObjFSOFile = objFSO.GetFile(Pf & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
                 Let MeActiveCell.Offset(Rw + 1, Clm) = ObjFSOFile.Size
                End If
             Let MeActiveCell.Offset(Rw + 2, Clm) = Format(objWSOFolder.GetDetailsOf(FldItm, 3), "dd,mmm,yy")
             Let MeActiveCell.Offset(Rw + 3, Clm) = Format(objWSOFolder.GetDetailsOf(FldItm, 4), "dd,mmm,yy")
             Let MeActiveCell.Offset(Rw + 4, Clm) = objWSOFolder.GetDetailsOf(FldItm, 166)
            '_________________________________________________________________________________________________
            ' 2b  Here we may pause the macro, whilst another copy of it is started
            If objWSOFolder.GetDetailsOf(FldItm, 2) = "Dateiordner" Then Call ReoccurringFldItmeFolderProps3(Pf & "\" & objWSOFolder.GetDetailsOf(FldItm, 0))
            '_________________________________________________________________________________________________
        '   If we did pause whilst the abobe code line set off another copy, then when that is finished we will come here and resume the paused previous copy
        Next FldItm ' ============================== Main Loop  =================================================|
     
     
     Let Reocopy = Reocopy - 1  ' We are finished at this point with this running copy of the macro. (The next code line ends it). This code line here will reduce the value used to keep track of the  copy number being run
    End Sub
    

  4. #24
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    Some extended notes to go with this Thread post answer
    https://eileenslounge.com/viewtopic....313747#p313747
    Hans set me straight with this nice concise bit https://eileenslounge.com/viewtopic....313743#p313743 , ( snb went off with a characteristic 80% Troll answer along the way, but I went along with it this time https://eileenslounge.com/viewtopic....313578#p313578
    https://eileenslounge.com/viewtopic....313622#p313622
    https://www.excelfox.com/forum/showt...ll=1#post23917
    )
    Finally another post from Hans, thereafter I had it clear ……..
    Quote Originally Posted by HansV
    https://eileenslounge.com/viewtopic....313747#p313747
    If you have opened only one window on the workbook, you can also use
    Workbooks("Book.xls").Windows(1).ActiveCell
    Interesting.
    I had a feeling there where multiple window possibilities around and it scared me a bit for a couple of reasons:
    _ one being I figured it would be something that I would easily get in a muddle with;
    _ the other reason being that how things can or do get displayed in multiple windows or multiple instances is a bit controversial I think

    Nevertheless, I took the plunge, and did try for the first time in my life to get a multiple workbook window. It was quite easy, (I did it manually, - there are plenty of simple tutorials on the internet to show you how), for example, with my first sample file, MeActiveStuff.xls , I ended up with these 2 windows after a couple of clicks
    MeActiveStuff.xls:1
    and
    MeActiveStuff.xls:2
    ( It demonstrates why I like to keep a few Excel versions, even some newer versions despite preferring older ones: In this case things will look a bit different for the multiple workbook window and that’s one of the controversial things some people get excited about, I believe. I am staying neutral on that one as I never needed multiple workbook windows, instanciated or not)
    https://i.postimg.cc/qRfGpY00/XL-201...-2-windows.jpg https://i.postimg.cc/cHQBCm43/XL-201...ws-1-and-2.jpg




    It is interesting though to help get this last bit of stuff a bit clearer in my mind, but at the same time, it's confirmed that it’s a bit confusing, at least for me: I think you have to be very very careful you don’t get mixed up……

    At first I thought the
    window item number and window caption name alternatives
    might be a parallel idea to the
    string tab name or item position number alternatives
    for a worksheet. Whether it is or not perhaps depends on your view point, literally and mentally

    This little demo macro might be useful for future reference: The main bits are 3 sets of 3 line sections. The first and third set of 3 lines are identical and the second is not much different.
    Code:
    Sub WorkbookWindowSCaptionNameAndItems()   '   https://eileenslounge.com/viewtopic.php?p=313747#p313747
    Rem 1
    ' 1a) Make a  ActiveCell  in  B2  of the first worksheet
    11 Workbooks("MeActiveStuff.xls").Windows.Item("MeActiveStuff.xls:1").Activate
    12 Workbooks("MeActiveStuff.xls").Worksheets.Item(1).Activate
    13 ActiveSheet.Range("B2").Select ' Effectively this will Make the ActiveCell in Workbooks("MeActiveStuff.xls"), Windows.Item("MeActiveStuff.xls:1") range B2 in the first worksheet
    ' 1b) Make a  ActiveCell  in  A2  of the second worksheet
    21 Workbooks("MeActiveStuff.xls").Windows.Item("MeActiveStuff.xls:2").Activate
    22 Workbooks("MeActiveStuff.xls").Worksheets.Item(2).Activate
    23 ActiveSheet.Range("A2").Select ' Effectively this will Make the ActiveCell in Workbooks("MeActiveStuff.xls"), Windows.Item("MeActiveStuff.xls:2") range A2 in the second worksheet
    Debug.Print "Rem 1 Results"
    Dim Windoe As Object, Cnt As Long
        For Each Windoe In ThisWorkbook.Windows
         Let Cnt = Cnt + 1
        Debug.Print Cnt & "  " & Windoe.Caption & "   " & ThisWorkbook.Windows.Item(Cnt).Caption & "   " & ThisWorkbook.Windows.Item(Cnt).ActiveCell.Address(, , , External:=True)
        Next Windoe
     Let Cnt = 0 ' You better do this or else in the next loop you will be trying to get at Item numbers above 2, and we aint got any
    Debug.Print
    Rem 2 repeat the first 3 lines - remake the first  ActiveCell  in  B2  of the first worksheet
    31 Workbooks("MeActiveStuff.xls").Windows.Item("MeActiveStuff.xls:1").Activate
    32 Workbooks("MeActiveStuff.xls").Worksheets.Item(1).Activate
    33 ActiveSheet.Range("B2").Select ' Effectively this will Make the ActiveCell in Workbooks("MeActiveStuff.xls"), Windows.Item("MeActiveStuff.xls:1") range B2 in the first worksheet
    Debug.Print "Rem 2 Results"
        For Each Windoe In ThisWorkbook.Windows
         Let Cnt = Cnt + 1
        Debug.Print Cnt & "  " & Windoe.Caption & "   " & ThisWorkbook.Windows.Item(Cnt).Caption & "   " & ThisWorkbook.Windows.Item(Cnt).ActiveCell.Address(, , , External:=True)
        Next Windoe
    
    
    End Sub
    If I have got it right, the 3 lines do the necessary to make the same two "ActiveCells" that my original Sub MesActiveCell() did. In that original attempt, I did not really make two ActiveCells , what really I did was set some memory of the last selection made on the two worksheets of the file MeActiveStuff.xls

    The third line set simply do exactly what the first did again. So there are really only two unique sets of 3 lines. Each unique set now actually makes a real ActiveCell from the same two selections I did before in my original Sub MesActiveCell()
    There are two similar sets of output results, the first set is given out after making the two ActiveCells,
    and the second results are given out after the first ActiveCell is made again. Obviously this last set of code lines is redundant, but it does something:
    Code:
     Rem 1 Results
    1  MeActiveStuff.xls:2   MeActiveStuff.xls:2   [MeActiveStuff.xls]Tabelle2!$A$2
    2  MeActiveStuff.xls:1   MeActiveStuff.xls:1   [MeActiveStuff.xls]Tabelle1!$B$2
    
    Rem 2 Results
    1  MeActiveStuff.xls:1   MeActiveStuff.xls:1   [MeActiveStuff.xls]Tabelle1!$B$2
    2  MeActiveStuff.xls:2   MeActiveStuff.xls:2   [MeActiveStuff.xls]Tabelle2!$A$2 
    The important thing to note is that the window Item number is reflecting the order of a ActiveCell being made, - you can see the order has swapped around. That can perhaps be related vaguely to Item number order in worksheets: If you remade the first worksheet or swapped around physically the tabs, you see a similar change in the Item number.
    In other words, the Window with the caption name and the ActiveCell is fixed, but the window item number can change: The item number is somehow related to the order of the things, the item number is not a number like a serial number/ string name using number characters

    So finally I think it is a bit too confusing for me to want to dabble very often with more than one window on the workbook. But at the same time it has helped me to get the thing a bit clearer, and so I think I will then go for this
    Code:
    Me.Activate: Dim MeActiveCell As Range: Set MeActiveCell = Workbooks(Me.Parent.Name).Windows.Item(1).ActiveCell ' https://eileenslounge.com/viewtopic.php?p=313747#p313747
    Somehow that does look a little better and rolls off my tongue that little bit subtly better than the last one and I think in my brain memory system will help me remember what it’s all about. Then I am happy I know about it enough not for it to annoy me quite so much. I gots a nice understanding now on this one,

  5. #25
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    l https://i.postimg.cc/qRfGpY00/XL-201...-2-windows.jpg https://i.postimg.cc/cHQBCm43/XL-201...ws-1-and-2.jpg






    Code:
    Sub WorkbookWindowSCaptionNameAndItems()   '   https://eileenslounge.com/viewtopic.php?p=313747#p313747
    Rem 1
    ' 1a) Make a  ActiveCell  in  B2  of the first worksheet
    11 Workbooks("MeActiveStuff.xls").Windows.Item("MeActiveStuff.xls:1").Activate
    12 Workbooks("MeActiveStuff.xls").Worksheets.Item(1).Activate
    13 ActiveSheet.Range("B2").Select ' Effectively this will Make the ActiveCell in Workbooks("MeActiveStuff.xls"), Windows.Item("MeActiveStuff.xls:1") range B2 in the first worksheet
    ' 1b) Make a  ActiveCell  in  A2  of the second worksheet
    21 Workbooks("MeActiveStuff.xls").Windows.Item("MeActiveStuff.xls:2").Activate
    22 Workbooks("MeActiveStuff.xls").Worksheets.Item(2).Activate
    23 ActiveSheet.Range("A2").Select ' Effectively this will Make the ActiveCell in Workbooks("MeActiveStuff.xls"), Windows.Item("MeActiveStuff.xls:2") range A2 in the second worksheet
    Debug.Print "Rem 1 Results"
    Dim Windoe As Object, Cnt As Long
        For Each Windoe In ThisWorkbook.Windows
         Let Cnt = Cnt + 1
        Debug.Print Cnt & "  " & Windoe.Caption & "   " & ThisWorkbook.Windows.Item(Cnt).Caption & "   " & ThisWorkbook.Windows.Item(Cnt).ActiveCell.Address(, , , External:=True)
        Next Windoe
     Let Cnt = 0 ' You better do this or else in the next loop you will be trying to get at Item numbers above 2, and we aint got any
    Debug.Print
    Rem 2 repeat the first 3 lines - remake the first  ActiveCell  in  B2  of the first worksheet
    31 Workbooks("MeActiveStuff.xls").Windows.Item("MeActiveStuff.xls:1").Activate
    32 Workbooks("MeActiveStuff.xls").Worksheets.Item(1).Activate
    33 ActiveSheet.Range("B2").Select ' Effectively this will Make the ActiveCell in Workbooks("MeActiveStuff.xls"), Windows.Item("MeActiveStuff.xls:1") range B2 in the first worksheet
    Debug.Print "Rem 2 Results"
        For Each Windoe In ThisWorkbook.Windows
         Let Cnt = Cnt + 1
        Debug.Print Cnt & "  " & Windoe.Caption & "   " & ThisWorkbook.Windows.Item(Cnt).Caption & "   " & ThisWorkbook.Windows.Item(Cnt).ActiveCell.Address(, , , External:=True)
        Next Windoe
    
    
    End Sub






















    Results



    Code:
     Rem 1 Results
    1  MeActiveStuff.xls:2   MeActiveStuff.xls:2   [MeActiveStuff.xls]Tabelle2!$A$2
    2  MeActiveStuff.xls:1   MeActiveStuff.xls:1   [MeActiveStuff.xls]Tabelle1!$B$2
    
    Rem 2 Results
    1  MeActiveStuff.xls:1   MeActiveStuff.xls:1   [MeActiveStuff.xls]Tabelle1!$B$2
    2  MeActiveStuff.xls:2   MeActiveStuff.xls:2   [MeActiveStuff.xls]Tabelle2!$A$2 
    The important thing to note is that the window Item number is reflecting the order of a ActiveCell being made, - you can see the order has swapped around. That can perhaps be related vaguely to Item number order in worksheets: If you remade the first worksheet or swapped around physically the tabs, you see a similar change in the Item number.
    In other words, the Window with the caption name and the ActiveCell is fixed, but the window item number can change: The item number is somehow related to the order of the things, the item number is not a number like a serial number/ string name using number characters

  6. #26
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    Later
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  7. #27
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    later

  8. #28
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    and later again

  9. #29
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    Rep Power
    10
    Some notes in support of this forum post
    https://eileenslounge.com/viewtopic....313848#p313848


    Hello,

    If you have time to help me make some coding I am sharing to anyone work in more languages and operating system, then please follow the Instructions below.
    So far I have results for:
    Operating systems XP, Vista, Win 7, Win 8.1, Win 10, Win 11 German
    Operating systems Win 10, Win 11 English



    Instructions
    Download both files and put them anywhere, but both in the same place
    WSO_PropNames.xls https://app.box.com/s/ynlabyb11ekmj6m4we99wk9xd7gx0xn3
    sample.wmv https://app.box.com/s/leu06ql1fu9uzt59wnoizedg85qoo7k4

    Open just WSO_PropNames.xls, it should look something like this, with columns AA and AB empty
    https://i.postimg.cc/QN9RhZsF/Before...ll-Details.jpg

    Attachment 5732

    Now run the only macro in it, WSO_PropNames.xls and run Sub SchellGetNullDetails() ( Tabelle8.SchellGetNullDetails
    https://i.postimg.cc/wxCnB4T0/Tabell...ll-Details.jpg

    Attachment 5733


    After running that coding, you should see something approximately like this
    https://i.postimg.cc/ZRg2pVPY/After-...ll-Details.jpg

    Attachment 5734



    Please now save the excel file and return it to me somehow: For example, post anywhere here at excelfox.com, or in that thread at https://eileenslounge.com , https://eileenslounge.com/viewtopic.php?f=30&t=40533

    Thanks,
    Alan
    Attached Images Attached Images
    Attached Files Attached Files

  10. #30
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,313
    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
  •