我一直在嘗試使用SaveAs2保存新的Word文檔,但無法解決該錯誤。這是我保存文件的代碼 word.Document newdocument = new word.Document(); newdocument = oword.Documents.Add(ref missing, ref missing, ref missing, ref missing); word.Range rng = newdocument.Range(0, 0); rng.Text = "start:\r\r" + content.Value.ToString(); rng.Text += "\rend:\r\r"; rng.Text += AnswerDictionary[content.Key.ToString()]; start = newdocument.Content.Start; end = newdocument.Content.End; range = newdocument.Range(ref start, ref end); range.Select(); range.Font.Size = 11; range.Font.Name = "Georgia"; rng.ParagraphFormat.Alignment = word.WdParagraphAlignment.wdAlignParagraphJustify; rng.ParagraphFormat.LineSpacingRule = word.WdLineSpacing.wdLineSpaceDouble; rng.ParagraphFormat.SpaceAfter = 0; rng.ParagraphFormat.SpaceBefore = 0; newfilename = @"C:\4PT\Output\" + content.Key.ToString() + ".docx"; //newdocument.SaveAs2(ref newfilename, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); newdocument.SaveAs2(ref newfilename);我收到此錯誤異常:拋出:“服務(wù)器引發(fā)了異常。(來自HRESULT的異常:0x80010105(RPC_E_SERVERFAULT))”(System.Runtime.InteropServices.COMException)引發(fā)了System.Runtime.InteropServices.COMException:“服務(wù)器引發(fā)了異常。來自HRESULT的異常:0x80010105(RPC_E_SERVERFAULT))“時間:2018/4/22 11:39:12 PM線程:[9556]請告訴我我在這里做錯了什么?
1 回答

江戶川亂折騰
TA貢獻(xiàn)1851條經(jīng)驗 獲得超5個贊
好的,我有問題。Saveas2僅用于Microsoft Office 2010,解決此問題的方法僅是使用Saveas而不是Saveas2。
- 1 回答
- 0 關(guān)注
- 342 瀏覽
添加回答
舉報
0/150
提交
取消