2
我對這個加載項編程不熟悉。 我的要求是我想爲來自c#的word文檔添加AfterSave事件。 我已經創建了Application_DocumentBeforeSave事件,但我想要保存事件後的文檔。如何爲Word文檔加載項創建AfterSave事件
任何一個可以幫助我解決這個..提前
感謝..
我對這個加載項編程不熟悉。 我的要求是我想爲來自c#的word文檔添加AfterSave事件。 我已經創建了Application_DocumentBeforeSave事件,但我想要保存事件後的文檔。如何爲Word文檔加載項創建AfterSave事件
任何一個可以幫助我解決這個..提前
感謝..
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.
}
感謝亞歷 –