日期:2014-05-18 浏览次数:20748 次
using Word = Microsoft.Office.Interop.Word public class word { Word.Application app; //Word应用程序变量 Word.Document doc; //Word文档变量 object missing = Type.Missing; public WordOper() { app = new Word.Application(); app.Visible = true; } public void Open() { doc = app.Documents.Open(ref _fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); } }
------解决方案--------------------
System.Diagnostics.Process.Start(FileName);足够了
------解决方案--------------------
用webbrowser也能打开
给它的URI属性赋 new Uri(@"X:\XX.doc");
------解决方案--------------------
System.Diagnostics.Process.Start会调用默认的关联程序打开
------解决方案--------------------
打开Word:
Word.Application wapp = new Microsoft.Office.Interop.Word.Application();
wapp.Visible = true;
wapp = null;
打开一个现有的Word文档:
Word.Application wapp = new Microsoft.Office.Interop.Word.Application();
wapp.Visible = true;
object filename = "E:\\Task.doc";
object isread = false;
object isvisible = true;
object miss = System.Reflection.Missing.Value;
wapp.Documents.Open(ref filename, ref miss, ref isread, ref miss, ref miss, ref miss, ref miss, ref miss,
ref miss, ref miss, ref miss, ref isvisible, ref miss, ref miss, ref miss, ref miss);
wapp = null;
打开一个新文档:
Word.Application wapp = new Microsoft.Office.Interop.Word.Application();
Word.Document adoc = new Microsoft.Office.Interop.Word.Document();
wapp.Visible = true;
object miss = System.Reflection.Missing.Value;
adoc = wapp.Documents.Add(ref miss, ref miss, ref miss, ref miss);
wapp = null;
添加using System.Reflection; using Microsoft.Office.Interop.Word; 引用
------解决方案--------------------
System.Diagnostics.Process.Start(FileName);
------解决方案--------------------
System.Diagnostics.Process.Start(@"c:\aa.doc");
这样就可以了。