Word VBA:如何知道实际保存操作是否完成?

发布于 2024-08-15 17:58:06 字数 280 浏览 2 评论 0原文

我在使用大型 Word 文档的 Word VBA 中的 Document.SaveAs 方法时遇到问题,似乎保存操作是异步的,即。调用.SaveAs后,它会立即返回,但对于大型Word文档,实际保存操作可能尚未完成,而是在另一个线程中进行。

那么我想问的是,是否有办法检测实际保存操作是否正在进行或已完成?

我用Delphi调用Word的自动化接口,如果讨论这个问题有意义的话,但我不这么认为?

I am having a problem with the Document.SaveAs method in Word VBA with large Word documents, it seems that the save operation is asynchronous, ie. after calling .SaveAs it returns immediately, but with large Word documents the actual save operation may not has been completed and it's in progress in another thread.

So what I want to ask is that if there is a way to detect if the actual save operation is in progress or finished?

I use Delphi to call the automation interface of Word, if it means something in discussing this problem, but I don't think so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

夜空下最亮的亮点 2024-08-22 17:58:06

办公自动化的 saveas 是进程外调用,因此它将始终在单独的进程上运行,因此本质上是异步的。

实际上没有办法捕获通知,除非它给出异常。

The saveas of the office automation is a out of process call, so it will always run on a seperate process, hence its asynchronous in nature.

There is literally no way to catch the notification unless it gives an exception.

执笏见 2024-08-22 17:58:06

它是:

If ActiveDocument.Saved = True then
/* 'do something */
End If

如果文档之前没有应用 .SaveAs,您也可以检查 .Path (即 If ActiveDocument.Path > "" 然后 ....)

请注意,后台保存是异步的,而不是您手动调用的保存 - 由 .Saved 检查。

It's:

If ActiveDocument.Saved = True then
/* 'do something */
End If

If the document has not had a .SaveAs applied against it before, you can check this the .Path as well (i.e. If ActiveDocument.Path <> "" Then ....)

Note that it is the Background Save that is asynchronous, not the Save which you invoke manually - that is checked by .Saved.

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