用这个不就好了?
object fileName = Environment.CurrentDirectory+"\\example.doc";doc.SaveAs ( ref fileName,ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional,
ref optional);
object fileName = Environment.CurrentDirectory+"\\example.doc";doc.SaveAs ( ref fileName,ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional,
ref optional);
File.Create(filePath);
OpenDoc(wordPath,filePath);private void OpenDoc(string extPath,string filePath)
{
Process p = new Process();
p.StartInfo.FileName=extPath;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Arguments=filePath;
p.Start();
}打开word的时候,总是弹出错误对话框,提示“文档的名称或路径无效……”
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
public static int Main (string[] argv)
{
Application app = new Application();
app.Visible=true; // Set up to create a plain, empty text document.
// Setting these variables to Missing.Value is comparable.
// to not providing a value for an optional parameter in VB.
// This gets the default behavior.
object template=Missing.Value; //No template.
object newTemplate=Missing.Value; //Not creating a template.
object documentType=Missing.Value; //Plain old text document.
object visible=true; //Show the doc while we work.
_Document doc = app.Documents.Add( ref template,
ref newTemplate,
ref documentType,
ref visible); Thread.Sleep (5000); //Display the empty document for 5 seconds.
doc.Words.First.InsertBefore ("This document is no longer empty!");
Thread.Sleep (5000); //Wait for 5 more seconds //Save the file, use default values except for filename.
object fileName = Environment.CurrentDirectory+"\\example2_new";
object optional = Missing.Value; //Take default values.
#if OFFICEXP
doc.SaveAs2000( ref fileName,#else
doc.SaveAs ( ref fileName,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
#endif
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional); // Now use the Quit method to cleanup.
object saveChanges = true;
app.Quit(ref saveChanges, ref optional, ref optional);
Console.Read();
return 0;
}
}
}