我一直在尝试使用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);
我收到此错误
异常:抛出:“服务器引发了异常。(来自HRESULT的异常:0x80010105(RPC_E_SERVERFAULT))”(System.Runtime.InteropServices.COMException)引发了System.Runtime.InteropServices.COMException:“服务器引发了异常。来自HRESULT的异常:0x80010105(RPC_E_SERVERFAULT))“时间:2018/4/22 11:39:12 PM线程:[9556]
请告诉我我在这里做错了什么?
江户川乱折腾
相关分类