下面是我东拼西凑的代码,程序不报错,但是没有任何响应。
private void button1_Click(object sender, EventArgs e)
{
SaveWord();
} private void SaveWord()
{ object otemp = System.Windows.Forms.Application.StartupPath + @"\实验.dot";
object oMiss = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
object readOnly = false;
Document doc = wordApp.Documents.Open(ref otemp, ref oMiss, ref readOnly, ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss,
ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss); doc.Activate(); //激活文档
doc.Application.PrintPreview = true;
doc.Application.ActiveDocument.PrintPreview(); //doc.PrintPreview();
}
private void button1_Click(object sender, EventArgs e)
{
SaveWord();
} private void SaveWord()
{ object otemp = System.Windows.Forms.Application.StartupPath + @"\实验.dot";
object oMiss = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
object readOnly = false;
Document doc = wordApp.Documents.Open(ref otemp, ref oMiss, ref readOnly, ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss,
ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss, ref oMiss); doc.Activate(); //激活文档
doc.Application.PrintPreview = true;
doc.Application.ActiveDocument.PrintPreview(); //doc.PrintPreview();
}
另外Office2003及以前版本可能和Office2007有些使用有些不一样,注意看是不是版本有问题
System.Diagnostics.Process.Start("notepad.exe");
你试试看,能不能用这个方法