I have an Excel 2007 .xltm workbook template with several connections to SQL Server. I did not list the xltm’s directory as a Trusted Location, so by default, external connections were disabled. This works well, because I have macros (signed & trusted) that would later enable these connections after a series of inputs using Workbook_Open.
However, I recently added the directory as a trusted location, and now the connections refresh automatically (regardless of Connection.ODBCConnection.RefreshOnFileOpen being set to False..)
So, I was hoping to find a simple command such as ActiveWorkbook.DisableConnections (since there is an ActiveWorkbook.EnableConnections…)
All I see is the read-only ActiveWorkbook.ConnectionsDisabled… How do I set it to true?
Figured it out. I run the following function once I’m done modifying the file, and this prevents the template from automatically refreshing the data.
Depending on my setup, I might swap
ODBCConnectionforOLEDBConnection.