如何不保存Word即可用Word打开想显示的内容!

时间:2023-03-09 03:28:32
如何不保存Word即可用Word打开想显示的内容!

  今天遇到客户需要将数据用Word预览,原来做的时候是保存到本地然后打开,客户说这样不好,因为不一定预览了一定要保存,于是我翻箱倒柜的发现真没资料啊!!幸好经过我的大量实验(好吧,我是挨个方法试的!),终于鼓捣出来了,一下就是代码,给自己写个备忘!

  Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document wordDoc = wordApp.Documents.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
Range P_Range = wordDoc.Paragraphs[].Range;
P_Range.Text = "AAAA";
wordApp.Visible = true;
wordApp.ShowMe();