打开Word文档时发生错误

问题描述:

你好.
我有示例代码:

Hello.
I have sample code:

  void myFunc()
{
   string UID = "Word.Application";
   System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

  Type appType = Type.GetTypeFromProgID(UID);
  if (appType == null) return;


  objApp = Activator.CreateInstance(appType);

   objApp.GetType().InvokeMember("Quit", BindingFlags.InvokeMethod, null, objApp, null);
 }



尝试关闭objApp时发生错误.我在这里http://support.microsoft.com/kb/827732/en-us
阅读 (简短地-打开Word文档时,模板宏中会出现一个对话框窗口)

我可以阻止显示此对话框吗?或如何以编程方式关闭它?

我尝试:



Whe objApp try to close an error is occured. I read about it here http://support.microsoft.com/kb/827732/en-us
(Shortly - when Word document is opened a dialog window appeares from template macro)

I can i prevent to show this dialog? Or How can i close it programmatically?

I try :

SendKeys.Send("{ESC}");

>



but it does not always work.

保存word文档的内容后,可以使用
关闭线程
After saving the content of word document, you can close thread using
Thread.Abort()



这是一种疯狂的方式;但最后一个选择.



Itz a wild way; but last option.


U必须更改Microsoft Office文档中的安全设置
U Have to change security settings in Microsoft Office documents