Process myProcess = new Process();
myProcess.StartInfo.FileName = path;
myProcess.StartInfo.Verb = "Open";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();        这个可以打开对应路径的文档,并且可以修改。如何设置使得只能查看,不能修改??  急急急!!!

解决方案 »

  1.   

    你可以考虑以下:
    1、将文档进行保护文档操作,这样用户是无法修改的。
    2、不将其修改后文档保存,你可以不保存就行了。
    推荐第一种。
    详细参看VBA for word。有详细解释
      

  2.   

    #region  读取word 
            /// <summary>
            /// 读取word所有文字内容(不包含表格)
            /// </summary>
            /// <returns>word中的字符内容(纯文本)</returns>
            public string ReadAllFromWord()
            {
                Word.ApplicationClass app = null;
                Word.Document doc = null;
                object missing = System.Reflection.Missing.Value;
                object FileName = m_FilePath;//@"E:\学习试验项目\ReadFromWordDoc\test.doc";
                object readOnly = true;
                object isVisible = false;
                try
                {
                    app = new Word.ApplicationClass();
                    doc = app.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);                string textString = "";
                    //读取全部内容
                    textString = doc.Content.Text.Trim();
    //                int ParCount = this.getParCount(doc);//段数
    //                for (int i = 1 ; i <= ParCount ; i++)
    //                {
    //                    textString = textString + doc.Paragraphs[i].Range.Text.Trim();//doc.Content.Text.Trim();//
    //                }
                    textString = textString.Replace("\a","");    //替换空串为空。(word中\a代表空串,但在C#中,代表响铃 晕~~)否则显示控制台程序时会响
                    textString = textString.Replace("\r","\n");    //替换回车为回车换行
                    return textString;      
                }
                catch(Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (doc != null)
                    {
                        try
                        {
                            doc.Close(ref missing, ref missing, ref missing);
                        }
                        catch
                        {}
                        doc = null;
                    }
                    if (app != null)
                    {
                        try
                        {
                            app.Quit(ref missing, ref missing, ref missing);
                        }
                        catch
                        {}
                        app = null;
                    }
                    GC.Collect();
                    GC.WaitForPendingFinalizers();            }
            }
            #endregion可以适当修改下。 需要引用word.dll
      

  3.   

    刚注意到此方法只能打开本地的文件,打不开服务器端的文件 用哪种方法可以打开服务器端的WORD文档???
      

  4.   

    如果是直接打开服务器的word可能需要写控件。