This project has moved. For the latest updates, please go here.

Outputing the edited template file.

Jan 15, 2016 at 10:14 PM
I have a file that I am using as a template file and I am using letter.ReplaceText to replace some text. Everything goes fine until I hit my final line.
 string filetemplate = @"C:\HEOProposalTool\TemplateDoc\Sales_HEO_Sample_Budgetary_Proposal.docx";
            string fileNameTemplate = @"C:\HEOProposalTool\FinalDocs\HEO-Proposal-{0}-{1}.docx";
            string CompName = this.compName.Text;
            string outputFileName = string.Format(fileNameTemplate, CompName, DateTime.Now.ToString("dd-MMM-yyyy"));
            DocX letter = DocX.Load(filetemplate);

//Process a bunch of letter.ReplaceText

Process.Start("WINWORD.EXE", "\"" + outputFileName + "\"");
WINWORD Opens but then it says it couldn't find my file. How can I create the file so that winword can find it? I am new to this library so I'm sure I missed a step.

-Phil
Developer
Jan 15, 2016 at 10:17 PM
How about saving the file after changes? And making sure the file actually exists on drive before trying to open word? Is the file created? Is it working when done manually?

Check SaveAs, Save.
Marked as answer by MadBoy on 1/16/2016 at 3:11 AM
Jan 15, 2016 at 10:51 PM
Actually, I just bypassed the process start word and used the DocX.SaveAs Function. Once, I did a deeper dive through the functions included in the library it made more sense. Its functioning 100%. Now if I could just get my relative paths to work :-(