我一直在使用以下代碼來編寫word文件,但無法存儲word文件。有什麼方法可以使用C#存儲單詞文件嗎?如何使用C保存doc文件
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
//Start Word and create a new document.
Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word._Document oDoc = new Microsoft.Office.Interop.Word.Document();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
//Insert a paragraph at the beginning of the document.
Microsoft.Office.Interop.Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = "Heading 1";
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
並且調用oDoc上的Save方法不起作用? http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._document.save.aspx另請參閱此處:http://msdn.microsoft.com/en-us/library/microsoft .office.interop.word._document_members.aspx – Icarus
或SaveAs:http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._document.saveas.aspx –