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?
method(ref info)
What you pass withref
should be of datatypeobject
- but that would throw a different error, not crash... – Cindy Meister