从 Access 2007 访问后 Excel 2007 工作簿被锁定
我有一个项目,我正在从 Excel 工作表读取数据并将其保存在 Access 表中(不是直接导入 - 请参阅这个问题(如果您有兴趣)。我当前的问题是,任何时候我运行“导入”,然后尝试在 Excel 中打开工作簿,它都会“锁定编辑”,除非/直到我关闭 Access。我认为情况不应该如此。我的流程是
- 使用自动化打开工作簿。
- 构建工作表名称的集合。
- 释放自动化对象。
- 如果有多个工作表,请获取要处理的用户输入。
- 打开特定范围内的 ADO 记录集读取一些数据。
- 释放记录集&联系。
- 在不同的特定范围内打开 ADO 记录集读取一堆数据。
- 释放记录集&联系。
- 关闭控制窗体。
步骤 1 - 4 和 9 位于表单文件中,其余部分位于模块中。
我错过了什么吗?我认为我已经发布了该工作簿的所有参考资料......
I've got a project where I'm reading data from an Excel worksheet and saving it in Access tables (not a direct import--see this question if you're interested). My current problem is that any time I run my "import" and then try to open the workbook in Excel, it's "locked for editing" unless/until I close Access. I don't think this should be the case. My process is
- Open the workbook with Automation.
- Build a collection of sheet names.
- Release the Automation objects.
- If there's more than one sheet, get user input on which to process.
- Open an ADO recordset on a specific range & read some data.
- Release the recordset & connection.
- Open an ADO recordset on a different specific range & read a bunch o' data.
- Release the recordset & connection.
- Close the controling form.
Steps 1 - 4 and 9 live in the form file, the remainder in a module.
Am I missing something? I think I've released all the references to the workbook....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的步骤 #1 包括这样的内容:
然后释放对象是这样的:
尝试在将对象变量设置为 Nothing 之前包含此行:
它还有助于使 Excel 应用程序实例在启动后可见,这样您就可以少可能会导致 Excel 运行不可见:
If your step #1 includes something like this:
And later releasing the object is this:
Trying including this line just before you set the object variable to Nothing:
It also helps to make the Excel application instance visible after starting it so you're less likely to leave Excel running unseen: