SQLite3Initialization fails with error 126

May 21, 2012 at 8:00 PM
Edited May 21, 2012 at 8:33 PM

I was able to successfully run the macro AllTests on the SQLiteForExcel workbook but if I transfer the macros to my workbook and attempt to execute just the SQLite3Initialization command, it fails with err 126. I have the latest sqlite3.dll and sqlite.def as well as sqlite3_stdcall.dll in the same folder. I also have the same references checked as the SQLiteForExcel workbook. Any clues as to what I can look for?

Thanks in advance

May 21, 2012 at 8:59 PM


You are probably getting error 126 from the LoadLibrary call. It means "The specified module could not be found" and refers to either sqlite3.dll or sqlite3_stdcall.dll which it can't load. You never need to redistribute sqlite3.def - it is just used when building sqlite3_stdcall.dll.

First check that you are sure which folder these libraries are in, say in C:\MyTest\

Then - the SQLite3Initialize call can take an optional path too - you can call it as

  result = SQLite3Initialize("C:\MyTest\") 

and it will check the given path.

(The default, if you leave out the parameter, is to use "ThisWorkbook.Path". Maybe print that value out from your code to see where it is actually looking.)


May 21, 2012 at 9:13 PM


LoadLibrary is returning 0 for SQLite3.dll, regardless of whether I supply the path argument or let it default. The path is as expected (workbook folder).

There seems to be some property on my workbook that isn't set properly, since I have the example workbook in the same folder and the TestAll macro

successfully accesses the SQLite3.dll and SQLite3_stdcall.dll. However when I switch to my workbook LoadLibrary always returns a 126 error.

May 21, 2012 at 10:56 PM

OK - maybe make a copy of the (working) example workbook, then move your other code into it?


May 21, 2012 at 11:38 PM

Update - I was not running from the folder that I thought I was. This problem is likely dumbness on my part.

Nice piece of work BTW! Very useful interface. Thanks for putting this together!