MS Access cannot connect to SAP "Cannot load LibRfc32.dll" error - VBA - SAP

1

How to fix librfc32.dll cannot be loaded error when calling from Microsoft Access 365?

I've tried the common troubleshooting steps found on the net as listed below and need help.

Note: This is a 25 year old complex large application and I cannot upgrade to a newer version than SAP GUI 7.40 as it is required for other applications. I cannot rewrite the web service call inside Access VBA as it is specifically excluded from my project. This is an Access 10 to Access 365 update project and has no time allocated for rewriting.

Note: This is a server machine and I cannot install DependencyWalker, Visual Studio or other diagnostic tools.

I get this error in Microsoft Access 365 when trying to send data to SAP using librfc32.dll:

Unable to load DLL 'librfc32.dll' The specified module could not be found.(Exception from HRESULT 0x8007007E)

The error is that librfc32.dll or one of the DLLs it depends on cannot be loaded.

Platform:

  • Windows Server 2016, 64 bit
  • Microsoft Access 365 32 bit
  • SAP GUI 7.40 patch level 13 front end tools application - SAP NetWeaver v7400.3.13.1130 - build 1756678 - patch level 13
  • Librfc32.dll is part of the SAP 7.40 GUI front end tools application

Notes:

  • We can't upgrade to SAP GUI 7.5 or later because it is used by other applications on the same machine
  • The MSAccess application is just upgraded from MSAccess 2010
  • The MSAccess application does not have any dependencies set for SAP DLLs or OCX files
  • Librfc32.dll depends on these other DLLs base on "dumpbin.exe /dependents librfc32.dll". Dumpbin.exe is part of Visual Studio 2019. Visual Studio 2019 is not installed on the machine having the cannot load DLL error.
  • Librfc32.dll dependencies - All of them are in C:\Windows\SysWow64. ole32.dll, RPCRT4.dll, OLEAUT32.dll, KERNEL32.dll, ADVAPI32.dll, USER32.dll, WS2_32.dll, IPHLPAPI.DLL, NETAPI32.dll, SHELL32.dll, dbghelp.dll, VERSION.dll, MSVCR110.dll

What we have tried so far and all gave the same cannot load DLL error:

  • Trial 1 - Run MSAccess application before SAP GUI 7.40 is installed
  • Trial 2 - Install SAP GUI 7.40
  • Trial 3 - In MSAccess application, add reference to C:\Windows\SysWow64\librfc32.dll
  • Trial 4 - Register librfd32.dll using "regsvr32 librfc32.dll"
  • Trial 5 - In MSAccess application, add references to the following DLLs from the SAP GUI application. This is from a similar Access 2010 SAP GUI 7.20 question from 2009 here and all of the DLLs exist on the machine having the error: https://answers.sap.com/questions/6537228/access-calls-sap-rfc-function-modules.html
    • regsvr32 c:\program files (x86)\sap\frontend\sapgui\wdobapi.ocx
    • regsvr32 c:\program files (x86)\common files\sap shared\wdtlog.ocx
    • regsvr32 c:\windows\SysWOW64\librfc32.dll
    • regsvr32 c:\program files (x86)\sap\frontend\sapgui\wdtaocx.ocx
    • regsvr32 c:\program files (x86)\sap\frontend\sapgui\wdtfuncs.ocx
  • Trial 6 - Examine the Windows event logs. Run the MSAccess application and produce the error message. Examine the Windows event logs again. No messages were found related to this error
  • Trial 7 - Copy librfc32.dll and librfc32u.dll to the Microsoft Office executable directory where MSAccess.exe is located
  • Trial 8 - Add C:\Windows\SysWow64 to PATH environment variable did not work. Start DOS, "SET PATH=%PATH%;C:\Windows\SysWow65; and then run MSAccess from the DOS command line
  • Trial 9 - Verified that msvcr110.dll, msvcp110.dll, MFC*.dll are in C:\Windows\SysWow64. Dumpbin.exe shows v110 of these DLLs as needed by librfc32.dll. This was referenced by https://answers.sap.com/questions/3505999/librfc32dll-not-found-on-windows-server-2003.html

Related reference links to similar problems with librfc32.dll. Note that these are up to 15 years old and many of the suggestions are for out of date applications.

I posted on StackOveflow after trying many many workarounds and reviewing over 50 web pages. I'd like to include some of the more close to this question links in this question but am limited with a too many links error.

vba
ms-access
dll
sap-gui
saprfc
asked on Stack Overflow Jan 21, 2021 by snj • edited Jan 21, 2021 by Sandra Rossi

1 Answer

1

librfc32.dll is the classic RFC library which was also part of the classic RFC SDK. It was also shipped with former SAP GUI releases and other products. But meanwhile the classic RFC library and the classic RFC SDK is out of maintenance and support at SAP. You won't get new releases or updates of this library anymore.

Which Visual C runtime libraries are required for this library depends on the SAP release which the librfc32.dll originates from and the bit width of the library (32-bit vs. 64-bit). Note that you always need the same bit width for all dynamically loaded libraries which must fit to the bit width of your main program that loads these libraries. So check if your MS Access executables are 32-bit or 64-bit programs.

Despite its name the librfc32.dll exists as 32-bit library and also as 64-bit library. In Windows directory SysWOW64 you will usually find 32-bit libraries whereas in directory system32 of a 64-bit Windows installation you will find the 64-bit libraries [Thank you Microsoft for that naming convention]. :)

Anyhow you do not need the librfc32u.dll which is the Unicode version of this library. You cannot use both in one process. Either your code is compiled for Unicode or it is not, and since you try to load librfc32.dll it seems to be compiled for a non-Unicode runtime.

answered on Stack Overflow Jan 22, 2021 by Trixx • edited Jan 22, 2021 by Trixx

User contributions licensed under CC BY-SA 3.0