解决方案 »
- 使用VS2005向SQL2005插入数据,表中没有此数据显示。
- XML解析
- 求救。。。安装SQLEXPRESS 提示 Rule“Cluster Node”failed
- SelectedValue报错
- c#自学的疑惑
- string 类型的赋值问题
- radiobutton使用
- 將DatagridView數據導出為Excel時,進程中多了一個Excel.exe進程,導致無法再打開Excel文件
- 怎样捕获C#控件(如Form,Panel)上的鼠标滚轮滚动事件?
- 聊天程序 关于socket流的问题!!!
- C# 如何判断电脑上是否己安装了SQL 服务
- C# odbc连接 oracle 未发现数据源名称并且未指定默认驱动程序 错误
private Word.Application G_wa;//定义Word应用程序字段
private object G_missing = //定义G_missing字段并添加引用
System.Reflection.Missing.Value;
private FolderBrowserDialog G_FolderBrowserDialog;//定义浏览文件夹字段
private object G_str_path;//定义文件保存路径字段 private void btn_New_Click(object sender, EventArgs e)
{
btn_New.Enabled = false;//将新建按钮设置为不可用
ThreadPool.QueueUserWorkItem(//开始线程池
(pp) =>//使用lambda表达式
{
G_wa = new Microsoft.Office.Interop.Word.Application();//创建应用程序对象
object P_obj = "Normal.dot";//定义文档模板
Word.Document P_wd = G_wa.Documents.Add(//向Word应用程序中添加文档
ref P_obj, ref G_missing, ref G_missing, ref G_missing);
G_str_path = string.Format(//计算文件保存路径
@"{0}\{1}", G_FolderBrowserDialog.SelectedPath,
DateTime.Now.ToString("yyyy年M月d日h时s分m秒fff毫秒") + ".doc");
P_wd.SaveAs(//保存Word文件
ref G_str_path,
ref G_missing, ref G_missing, ref G_missing, ref G_missing,
ref G_missing, ref G_missing, ref G_missing, ref G_missing,
ref G_missing, ref G_missing, ref G_missing, ref G_missing,
ref G_missing, ref G_missing, ref G_missing);
((Word._Application)G_wa.Application).Quit(//退出应用程序
ref G_missing, ref G_missing, ref G_missing);
this.Invoke(//调用窗体线程
(MethodInvoker)(() =>//使用lambda表达式
{
MessageBox.Show(//提示已经创建Word
"成功创建Word文档!", "提示!");
btn_display.Enabled = true;//启用显示按钮
}));
});
}