How to troublshoot updating to MSOLEDBSQL driver that is breaking macro-enabled Excel book?
0
votes
0
answers
1277
views
I have an Excel macro-enabled file (.xlsm) with VBA that builds various SELECT statements and also executes a stored procedure on a SQL Server DB in order to populate a table. It is from a legacy system and uses an old deprecated driver (MSOLEDB.1), and I am trying to update it to read from a new database, while updating the driver as well.
I've updated the new connection string in the VBA code from using Provider=MSOLEDB.1 to the new MSOLEDBSQL driver (which is installed on new SQL Server). I can step through the code and all executes perfectly. I can run the macro from the refresh button on the sheet, all good. *But when I save and close the file, and then attempt to re-open it - upon hitting Enable for the macro warning, it hangs excel.* When I change it back to the old string, all works fine again- I can close and reopen the file, and re-run the code with no issues.
I can include more detail about both old and new environment, but I wanted to see if anyone even has any suggestions of how to troubleshoot this. The key difference is that old string authenticated via SQL login and the new one via Windows. (I don't want to authenticate via SQL login moving forward.)
Old (sensitive data replaced):
**"PROVIDER=SQLOLEDB.1;DATA SOURCE=#.#.#.#\SQLEXPRESS;INITIAL CATALOG=Databasename;NETWORK=DBMSSOCN;USER ID=SQLUser;PASSWORD=password;"**
New:
**"Provider=MSOLEDBSQL;Server=servername;Database=Databasename;Trusted_Connection=yes"**
Running Debug->Compile VBA Project has sorted out buggy things like this before, but not this time. I've tried recompiling every sheet with code (even added comments to sheets with no codes so I could recompile them) but no effect.
I also tried adding the ForceVBALoadFromSource from which had no effect.
I believe it has either something to do with the new driver with Windows authentication, but I am really hoping for some hints.
Asked by hap76
(15 rep)
Apr 17, 2020, 09:10 PM