从 Access 2007 访问后 Excel 2007 工作簿被锁定

发布于 2024-10-01 04:29:23 字数 597 浏览 0 评论 0原文

我有一个项目,我正在从 Excel 工作表读取数据并将其保存在 Access 表中(不是直接导入 - 请参阅这个问题(如果您有兴趣)。我当前的问题是,任何时候我运行“导入”,然后尝试在 Excel 中打开工作簿,它都会“锁定编辑”,除非/直到我关闭 Access。我认为情况不应该如此。我的流程是

  1. 使用自动化打开工作簿。
  2. 构建工作表名称的集合。
  3. 释放自动化对象。
  4. 如果有多个工作表,请获取要处理的用户输入。
  5. 打开特定范围内的 ADO 记录集读取一些数据。
  6. 释放记录集&联系。
  7. 在不同的特定范围内打开 ADO 记录集读取一堆数据。
  8. 释放记录集&联系。
  9. 关闭控制窗体。

步骤 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

  1. Open the workbook with Automation.
  2. Build a collection of sheet names.
  3. Release the Automation objects.
  4. If there's more than one sheet, get user input on which to process.
  5. Open an ADO recordset on a specific range & read some data.
  6. Release the recordset & connection.
  7. Open an ADO recordset on a different specific range & read a bunch o' data.
  8. Release the recordset & connection.
  9. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单调的奢华 2024-10-08 04:29:23

如果您的步骤 #1 包括这样的内容:

Dim objExcel As New Excel.Application

然后释放对象是这样的:

Set objExcel = Nothing

尝试在将对象变量设置为 Nothing 之前包含此行:

objExcel.Quit

它还有助于使 Excel 应用程序实例在启动后可见,这样您就可以少可能会导致 Excel 运行不可见:

objExcel.Visible = True

If your step #1 includes something like this:

Dim objExcel As New Excel.Application

And later releasing the object is this:

Set objExcel = Nothing

Trying including this line just before you set the object variable to Nothing:

objExcel.Quit

It also helps to make the Excel application instance visible after starting it so you're less likely to leave Excel running unseen:

objExcel.Visible = True
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文