禁用工作簿连接
我有一个 Excel 2007 .xltm 工作簿模板,其中有多个与 SQL Server 的连接。我没有将 xltm 的目录列为受信任位置,因此默认情况下外部连接被禁用。这很有效,因为我有宏(已签名且受信任),稍后可以在使用 Workbook_Open 进行一系列输入后启用这些连接。
但是,我最近将该目录添加为受信任位置,现在连接会自动刷新(无论 Connection.ODBCConnection.RefreshOnFileOpen
设置为 False
..
)希望找到一个简单的命令,例如 ActiveWorkbook.DisableConnections
(因为有一个 ActiveWorkbook.EnableConnections
...)
我看到的只是只读ActiveWorkbook.ConnectionsDisabled
...如何将其设置为 true?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了。完成文件修改后,我运行以下函数,这会阻止模板自动刷新数据。
根据我的设置,我可能会将
ODBCConnection
替换为OLEDBConnection
。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
ODBCConnection
forOLEDBConnection
.