Runtime Error 48: “Error in loading DLL,” explained and fixed

Error 48, “Error in loading DLL”, fires when VBA (or a Declare call) tries to load a dynamic-link library and Windows refuses. The file may not exist, may be 32-bit while the host is 64-bit (or the reverse), may be damaged, or may itself depend on another DLL that is missing. The error never names the real culprit directly, so the work is identifying which library the failing line tried to load and testing it in isolation.

For people who just run the program

  1. Note whether the program was recently installed, moved, or updated. Error 48 typically begins right after a change: a copied program folder missing its libraries, an update that replaced some files but not others.
  2. Check 32-bit versus 64-bit Office. If the error started when Office was reinstalled or upgraded, a bitness mismatch with an old add-in or library is the prime suspect. The version is under File, Account, About.
  3. Reinstall the program rather than copying DLLs by hand. A library usually needs specific companion files and registration; dropping in a same-named file from the internet is both unreliable and a security risk.
  4. Report what changed before the error started. For error 48, the change history is more diagnostic than the error text.

For people who write the code

  1. Find the exact Declare or reference that fails. Step to the failing line; the library name in the Declare statement, or the checked reference, is the file to investigate.
  2. Private Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
    ' Error 48 here means the named library (or one of ITS imports)
    ' could not be loaded, not that the function name is wrong.
  3. Separate “DLL missing” from “dependency missing.” A DLL whose own imports are absent fails to load even though the file is present. A dependency walker (or the vendor's redistributable installer, commonly the Visual C++ redistributables) resolves the second case.
  4. Match bitness deliberately. 64-bit VBA can only load 64-bit DLLs, 32-bit only 32-bit. Declare statements need PtrSafe on 64-bit, but PtrSafe does not make a 32-bit library loadable.
  5. Verify the search path. A bare library name is searched in standard locations; if the DLL lives in the application folder, confirm the running program's folder is where you think it is, especially for documents opened from email or archive previews.
Never download individual DLL files from DLL-download sites. They are a classic malware channel and frequently the wrong version. The correct source is always the software vendor's installer or Microsoft's redistributable packages.

If it still happens

If the DLL loads in a test harness but not from the document, the difference is the working directory or the host process: Office hosts resolve relative library names against their own search path, not the document's folder. Use a full path in the Declare (in a controlled location) to remove the ambiguity, and re-test.

Common questions

What is the difference between error 48 and error 453? Error 48 means the library itself could not be loaded at all. Error 453 means the library loaded but the named function was not found inside it. They point at different layers of the same Declare mechanism.

Can a missing Visual C++ redistributable cause error 48? Yes. Many DLLs are built on the Microsoft C runtime; if that runtime is absent, the DLL fails to load and the caller sees error 48 even though the named file exists.

Related errors

Runtime Error 49 · Runtime Error 453 · Runtime Error 429