2

I want to assign an ArrayList to a variable.

Sub Create_ArrayList()
    Dim arrL As Object

    'Creating an ArrayList, option 1 - fails
    Set arrL = CreateObject("System.Collections.ArrayList")

    'Creating an ArrayList, option 2 - fails
    Set arrL = GetObject("New:{6896B49D-7AFB-34DC-934E-5ADD38EEEE39}")
End Sub

Both options fail :

Run-time error '-2146232576 (80131700)':
Automation error

I found that the CLSID exists in the registry in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID

CLSID registry system.collections.arraylist

The Office is 32-bit and Windows is 64-bit. I am not familiar with the registry, but it seems from what I have read, that 32-bit Office is trying to find ArrayList in some 32-bit Windows location (view), while it actually is in 64-bit location. Can it be the case? How to make the application get ArrayList from the correct location?

It seems, to access an alternative registry view, I should somehow use the flag KEY_WOW64_64KEY (value 0x0100), but the examples that I found are too big to comprehend (eg1, eg2). I don't want to edit registry data, I only want to tell VBA that I am using 64-bit Windows, so the object that I need is to be found somewhere else than it expects.

ZygD
  • 22,092
  • 39
  • 79
  • 102
  • 1
    Based on this link, I'd try installing the .Net 2 SP2 framework: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9bfcd001-5168-4cff-b2ba-6b8e8d465138/excel-2010-vb-runtime-error-2146232576-80131700-automation-error-on?forum=exceldev – Rory Aug 14 '18 at 15:15
  • you must have .Net framework installed indeed. – QHarr Aug 14 '18 at 16:05
  • 1
    Looking at the 64 bit view won't help because your 32 bit process needs a 32 bit inproc server. Then again, do you really need to use a .net ArrayList to solve your problem? Why not code it in pure VBA? – David Heffernan Aug 14 '18 at 17:23
  • I saw that page where it says that .Net framework is needed. But after seeing `System.Collections.ArrayList` in registry, I thought that it should work.. how did it get there, if it does not exist? Or it exists, but I just can't reach it without .Net framework? – ZygD Aug 14 '18 at 20:14
  • @DavidHeffernan - I often find myself performance-oriented. This option seems promising performance-wise, because it naturally has `.Sort` method, so I would not need to write VBA array sorting function, which I have already reviewed [here](https://stackoverflow.com/questions/152319/vba-array-sort-function). But again, if .Net framework is needed, I would not be able to distribute the file to others so that I'm guaranteed it would work there. – ZygD Aug 14 '18 at 20:20

0 Answers0