Search code examples
excelvbawindows-8odbcdao

Excel VBA DBEngine.CreateWorkspace fails saying cannot load DLL


I have a legacy business application written in VBA in Excel. It uses the VBA DAO library (installed at c:\program files (x86)\Common Files\Microsoft Shared\DAO\dao360.dll) and the classes Workspace, Database, DBEngine, Connection) to connect to a SQL database via ODBC.

It works properly up to Windows 7, but on Windows 8 /Server 2012, it doesn't work, on the very first call to DAO:

Set ws = DBEngine.CreateWorkspace(wsName, "", "", dbUseODBC)

raises a runtime error number 3633 description "Cannot load DLL: 'msrdo20.dll'". This occurs both in the class library's DBEngine.Errors and the regular VBA Err object.

This error occurs whether or not the file msrdo20.dll exists.

I found https://support.microsoft.com/en-us/kb/260369 which says to include ODBCDirect, but that doesn't seem to be relevant.

I found http://www.xtremevbtalk.com/archive/index.php/t-172385.html which suggests removing Microsoft DAO 3.6 from the references and switching to DAO 3.5 -- but doing that breaks things even worse, I get run-time error 429, "ActiveX component can't create object".

This is Windows Server 2012, Excel 2013.


Solution

  • This blog solved that problem for me:

    http://pwaldman.com/unable-to-load-msrdo20-dll-or-rdocurs-dll/

    Extract:

    Resolution

    1. Download Service Pack 6 for Visual Basic 6.0 (Vs6sp6.exe)

    http://www.microsoft.com/en-us/download/details.aspx?id=9183

    1. Run Vs6sp6.exe and extract the files
    2. Open msrdo20.cab, it contains the following files: MSRDO20.DLL, MSRDO20.INF, and RDOCURS.DLL. Extract all three files and copy them to the C:\Windows\SysWOW64\ directory.
    3. Open an elevated(admin) command prompt, navigate to C:\Windows\SysWOW64, and register MSRDO20.DLL. The RDOCURS.DLL does not need to be registered.

       C:\Windows\System32> cd C:\Windows\SysWOW64
       C:\Windows\SysWOW64> regsvr32 MSRDO20.DLL