class does not support automation RTE 430

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15632
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

class does not support automation RTE 430

Post by ChrisGreaves »

I have used this code since about 1998; it is my VBA code harvester that scours a hard drive collecting every scrap of VBA code.
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"
Untitled.png
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
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle

User avatar
HansV
Administrator
Posts: 78510
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: class does not support automation RTE 430

Post by HansV »

I don't get an error on my PC (Windows 11 Home 64-bit, Office 2021 32-bit).
Does this work?

Code: Select all

    Dim SH As Shell32.Shell
    Set SH = New Shell32.Shell ' or CreateObject(Class:="Shell32.Shell")
    With SH
        ...
    End With
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15632
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: class does not support automation RTE 430

Post by ChrisGreaves »

HansV wrote:
21 Mar 2023, 16:01
I don't get an error on my PC (Windows 11 Home 64-bit, Office 2021 32-bit).
Does this work?
Thank you Hans. I have to say "Yes" because on this run it did not fail where it had previously failed.
Untitled3.png
:blush: It now fails on a line "app.Quit" where app happens to be an Excel workbook or similar, so at least it is now processing the 000,000s of files that it found.

In the meantime I have a few quick tests I should perform:
The current application is Proje167.dot, so I might try
(1) Is this the first time through that code i.e. my first (of 000s) of App.Quit calls?
    Yes. This suggests that I am not opening Excel workbooks correctly from Word/VBA ("Well it was working under Win10, Win7, WinXp, Win95 ")
(2) The previous two versions - just to see if they can harvest code and store a library file (*.lib)
    No. They both fail on the App.Quit with an Excel workbook
(3) Rob Bovey's CodeCleaner sometimes clears up weird corruption errors (in Proje167.dot we're looking at 19 hefty code modules, plus 13 frm)
     No. I get that "The disk is full" pop up which usually signals corruption.
I shall create an uncorrupted version of Proj as a top priority.
(4) Something less ambitious than T:\ with its 265,314 objects; perhaps "t:\greaves\products\devel\turing\" with a mere 775 objects.
    No. This still crashes on the App.Quit where App had been assigned an Excel workbook.
(5) Instead of creating a library ("Harvest" code) try searching a pre-exisitng library
     Yes. The current version (saved as Proje168 to avoid making changes to Proje167) searches existing LIB files just great. (Hooray)
(6) Try harvesting a folder that contains ONLY *.DO* files
    Yes. Worked fine in T:\Greaves\Products\DEVEL\AddIn in (a) harvesting and (b) searching the harvested code.

So, I had better start again with an uncorrupted version.
More later ...
Thanks, Chris
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle