当前位置:编程学习 > C#/ASP.NET >>

c#打开Word损坏文档停住了

在打开Word文档中出现打开损坏的文档停住了,如何跳过。
出现的对话框提示如下:
上次要开文档“xxx.doc”时出现严重错误。是否继续打开它?是/否
我希望Open操作的时候不要停在那里。 --------------------编程问答-------------------- 无人回答吗? --------------------编程问答-------------------- 把Excel.ApplicationClass的DisplayAlerts 改为 false; --------------------编程问答-------------------- Application.SendKeys ("{ENTER}") 

Application.DisplayAlerts = False 

再通过try catch判断 --------------------编程问答-------------------- Excel.ApplicationClass的DisplayAlerts 改为 false;
try
catch --------------------编程问答-------------------- 不是这个问题,我已经设置过了是一样的,还有就是有的文件损坏了恢复会出现恢复对话框,如何去掉也是问题,代码如下:
Word.Application app=null; 
Word.Document doc=null; 
object filename=FileName.Text.Trim(); 
object isVisible = false; 
object readolny=false; 
object nullobj=Type.Missing; 
try 

app=new Word.ApplicationClass(); 
app.DisplayAlerts=Word.WdAlertLevel.wdAlertsNone; 
doc=app.Documents.Open(ref filename,ref nullobj,ref readolny,ref nullobj, 
ref nullobj,ref nullobj,ref nullobj,ref nullobj,ref nullobj, 
ref nullobj,ref nullobj,ref isVisible,ref nullobj,ref nullobj, 
ref nullobj,ref nullobj);//此处出现修复文件对话框,我希望能不出现对话框,跳过。 

catch(Exception ex) 

ex.ToString(); 

finally 

try 

if(doc!=null) 
doc.Close(ref nullobj,ref nullobj,ref nullobj); 

catch(Exception wex) 

wex.ToString(); 

try 

if(app!=null) 
app.Quit(ref nullobj,ref nullobj,ref nullobj); 

catch(Exception aex) 

aex.ToString(); 


另一个我发的贴
http://topic.csdn.net/u/20091013/11/5386f4bf-4012-4d39-98e2-e3176bc933e9.html --------------------编程问答-------------------- 學習··· --------------------编程问答--------------------
补充:.NET技术 ,  组件/控件开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,