1
我需要在Word中禁用SaveAs或防止用戶更改文件名。在Word中禁用SaveAs
我的應用程序允許用戶使用頭文件我爲它們提供程序創建一個MailMerge文檔。當用戶只是簡單地保存並退出Word時,此功能就可以工作。如果用戶另存爲,應用程序將被鎖定。我正在使用Microsoft.Office.Interop.Word
。
//MyWordApp & doc is initialized.
MyWordApp.Application.Visible = true;
While(WordIsOpen())//Holds execution here while User is editing in Word
{
}
WordIsOpen定義:
public bool WordIsOpen()
{
if (MyWordApp.Application.Visible)//Locks up here
{
return true;
}
else
return false;
}
禁售:
//I have a BeforeSave event that Saves the doc and quits Word
DocumentBeforeSave(Doc, SaveAsUI, Cancel)
{
//Save Doc
MyWordApp.Quit(ref objFalse, ref objNull, ref objNull);//Also, Locks up here
}
爲什麼不修復它,使應用程序不鎖定? – Ghost 2012-07-16 20:10:58
確定爲什麼應用程序鎖定並解決該問題不是更有意義嗎? – CaffGeek 2012-07-16 20:11:05
我試過修復它。我改變了我一直在做的方式。走完整個圈子,最後回到你在這裏看到的方法。 – ExceptionLimeCat 2012-07-16 20:39:17