用process.start("333.doc");
这样就会自动打开Word程序;
这样就会自动打开Word程序;
解决方案 »
- 使用DataTable时,遇到“未将对象引用设置到对象的实例”错误
- 一个主窗口(包括登录,时间限制,前一页后一页主页导航),主窗口内有多个网站链接,点击后加载web页,可以前进后退回到主页
- 如何判断操作系统当前是否进入屏保状态,是用哪个API函数吗?
- radiobuttonlist 添加dropdownlist
- 请问在设计WEB页面时,如何使TreeView显示滚动条。
- 谁能够详细讲一下抽象类和接口、虚函数和抽象函数的区别吗?
- 数字三位一撇加逗号能用正则表达式实现吗?
- ====对不起,求:超时时间已到。在从池中获取连接之前超时时间已过...的终极解决方法!
- 如何自己写报表设计器?
- 请问可以c#开发PDA的软件吗,可以做串口通讯吗,怎么做,谢谢
- 各位大哥,谁知道哪有《C#入门经典》的习题答案?请告诉我。谢谢!
- c#中#是什么意思?
**********************
using System;
using System.Threading;
using System.Reflection;
using Word;public class MainClass
{
public static int Main (string[] argv)
{
//这相当于 CoCreateInstance
Application app = new Application();
//确保 Word 可见
app.Visible=true;
//设置以创建一个空的纯文本文档
// 将这些变量设置为 Missing.Value 可视为向
// 函数中传递空。这一点很有必要,因为引用不能
// 传递 C# 空。
object template=Missing.Value;
object newTemplate=Missing.Value;
object documentType=Missing.Value;
object visible=true;
_Document doc = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible); Thread.Sleep (5000); //显示空文档五秒钟
doc.Words.First.InsertBefore ("This document is no longer empty!");
Thread.Sleep (5000); //再等待五秒钟 //保存文件,并使用默认值(文件名除外)
object fileName = Environment.CurrentDirectory+"\\example2";
object optional = Missing.Value;
#if OFFICEXP
doc.SaveAs2000( ref fileName,
#else
doc.SaveAs ( ref fileName,
#endif
ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional, ref optional); // 现在像好用户一样,使用 Quit 方法进行清理
object saveChanges = true;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
app.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
return 0;
}
}