saveas方法只能用绝对路径,不能用相对路径,这个问题倒腾了好久,并且 Microsoft.Office.Interop.Word._Application 需要设置为不可见
object oMissing = System.Reflection.Missing.Value; //创建一个Word应用程序实例 Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application(); //设置为不可见 oWord.Visible = true; Microsoft.Office.Interop.Word._Document oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); //弹出保存文件对话框,保存生成的Word SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Word Document(*.doc)|*.doc"; sfd.DefaultExt = "Word Document(*.doc)|*.doc"; if (sfd.ShowDialog() == DialogResult.OK) { object filename = sfd.FileName; oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oDoc.Close(ref oMissing, ref oMissing, ref oMissing); //关闭word oWord.Quit(ref oMissing, ref oMissing, ref oMissing); }