我的代码是这样写的:
 object oMissing = System.Reflection.Missing.Value;
 object fileName = http;//路径                          
 Word.Application wordApp = new Word.Application();//新建WORD模板
 wordApp.Visible = false;
 Word.Document wordDoc = wordApp.Documents.Open(ref fileName,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing);执行到打开文件这句时,总显示:“文件'Normal.doc'已存在,是否替换原有文件!”我现在不想让它屏蔽这种情况,请 高手 赐教!

解决方案 »

  1.   

                Word.ApplicationClass WordApp = new Word.ApplicationClass();            // give any file name of your choice. 
                object fileName = "D:\\aa.doc";
                object readOnly = false;
                object isVisible = false;            //  the way to handle parameters you don't care about in .NET 
                object missing = System.Reflection.Missing.Value;
                WordApp.Visible = false;
                //   Make word visible, so you can see what's happening 
                //WordApp.Visible = true; 
                //   Open the document that was chosen by the dialog 
                Word.Document aDoc = WordApp.Documents.Open(ref fileName,
                                        ref missing, ref readOnly, ref missing,
                                        ref missing, ref missing, ref missing,
                                        ref missing, ref missing, ref missing,
                                         ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);            Word.WdStatistic stat = Word.WdStatistic.wdStatisticPages;
                int num = aDoc.ComputeStatistics(stat, ref missing);
                System.Console.WriteLine("The number of pages in doc is {0}",
                                          num);            foreach (Word.Range r in aDoc.Words)
                {
                    Debug.WriteLine("value:" + r.Text);            }            System.Console.ReadLine();
                object o = false;
                aDoc.Close(ref o, ref missing, ref missing);
                WordApp.Quit(ref o, ref missing, ref missing);
      

  2.   

    Word.Document wordDoc = wordApp.Documents.Open(fileName,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing);