The Function GetFolderItems recursively builds an array of folder names which names are then processed serially.
This is my first run of this particular application [Word2003/VBA under Windows 11], so I suspect that my reference to Microsoft Shells and Controls Automation is at fault.
The code fails on the statement "With New Shell"
I suspect too, that I use this reference in several other applications, but quite possibly I have not used those applications on this new machine. Yet.
I would appreciate knowing of an alternate DLL that might work, My understanding is limited. I believe that this is a 64-bit system, but all the MSWord stuff for me is 32-bit.
The attached image is a result of asking Everything.exe for all shell32.dll objects.
The attached stripped-down TEST in Doc2.DOC runs to completion (in record time on my SSD!), so I think that the code is OK. It is a plain copy/paste from the harvesting application, and is hooked up to the same Shell32.dll.
Thanks for any hints or clues
Chris
Code: Select all
Public Function GetFolderItems(folder As String, strAr() As String)
' needs a reference to microsoft shells and controls automation
' On Error Resume Next
Dim FI As Shell32.FolderItem, i As Long
With New Shell ''''' FAILS HERE
'evaluate the namespace
With .NameSpace(folder)
For Each FI In .Items
If Not (FI Is Nothing) Then
If FI.IsFolder Then
'evaluate this namespece
Call GetFolderItems(FI.Path, strAr)
Else
'add to dictionary
strAr(UBound(strAr)) = BuildPath(folder, FI.Name)
ReDim Preserve strAr(UBound(strAr) + 1)
End If
End If
Next
End With
End With
Set FI = Nothing
End Function
Sub TESTGetFolderItems()
Dim strFoldername As String
strFoldername = "T:\"
' strFoldername = "T:\users\Chris074\Microsoft\Windows\AccountPictures\"
' strFoldername = "T:\Greaves\Admin\2015\EasyHosting\Automated 30 Day Renewal Reminder 2015-06-17 - cprgreaves@gmail.com - Gmail_files\"
' strFoldername = "T:\Greaves\Admin\2015\EasyHosting\Automated 30 Day Renewal Reminder 2015-06-17 - cprgreaves@gmail.com - Gmail_files"
Dim strAr() As String
ReDim strAr(0)
Call GetFolderItems(strFoldername, strAr)
End Sub