gpt4 book ai didi

c# - 如何为 Word 文档加载项创建 AfterSave 事件

转载 作者:行者123 更新时间:2023-11-30 14:49:38 24 4
gpt4 key购买 nike

我是这个插件编程的新手。我的要求是我想从 c# 为 word 文档添加 AfterSave 事件。我已经创建了 Application_DocumentBeforeSave 事件,但我想要文档保存后事件。

谁能帮我解决这个问题..

提前致谢..

最佳答案

private void Application_DocumentBeforeSave(Document Doc, ref bool SaveAsUI, ref bool Cancel)
{
new Thread(() =>
{
while (true)
{
try
{
var application = document.Application; // This is inaccessible while the save file dialog is open, so it will throw exceptions.
while (application.BackgroundSavingStatus > 0) // Wait until the save operation is complete.
Thread.Sleep(1000);
break;
}
catch {
Thread.Sleep(1000);
}
}
// If we get to here, the user either saved the document or canceled the saving process. To distinguish between the two, we check the value of document.Saved.
Application_DocumentAfterSave(document, !document.Saved);
}).Start();
}

private void Application_DocumentAfterSave(Document Doc, bool isCanceled) {
// Handle the after-save event. Note: Remember to check isCanceled.
}

关于c# - 如何为 Word 文档加载项创建 AfterSave 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38455862/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com