I've been trying to save my new word document using SaveAs2 but couldn't resolve the error. This is my code to save file
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);
I am getting this error
Exception:Thrown: "The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))" (System.Runtime.InteropServices.COMException) A System.Runtime.InteropServices.COMException was thrown: "The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))" Time: 4/22/2018 11:39:12 PM Thread:[9556]
Kindly tell me what i'm doing wrong here?
Okay, i've got the problem. Saveas2 was only for Microsoft office 2010 and the solution to this problem was only to use Saveas instead of Saveas2.
User contributions licensed under CC BY-SA 3.0