I have a Winforms app that utilizes a dll (docX) to create a .docx document from a StringBuilder. I'm trying to open that document with Microsoft Word (the default program) with a button click. I tried the folowing code but I keep getting errors. Can someone point me in the right direction to accomplish this?
private void button3_Click(object sender, EventArgs e)
{
var x = "";
using (DocX document = DocX.Create("Testdocx.docx"))
{
document.MarginTop = 25f;
document.MarginBottom = 25f;
document.MarginLeft = 25f;
document.MarginRight = 25f;
Paragraph p = document.InsertParagraph();
FontFamily fontFamily = new FontFamily("Courier New");
p.Append(sb.ToString()).Font(fontFamily).FontSize(8); //where "sb" is a StringBuilder
document.Save();
x = Environment.CurrentDirectory;
}
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE";
startInfo.Arguments = x + "\\Testdocx.docx";
startInfo.UseShellExecute = true;
Process.Start(startInfo);
}