I have use mail merge to word from instructor below. Now in last line it’s going to save the word file but I don’t want to save that I just want to open it without saving! What should I do for it? My mail merge instruction: https://vivekcek.wordpress.com/2012/08/25/create-a-word-document-from-a-template-using-c-mail-merge/
Mail merge without saving c#
412 views Asked by Seena Fallah At
2
There are 2 answers
3
On
The code in that link has nothing to do with a mailmerge; all it's doing is showing how to create a template using mergefields as placeholders, then using C# code to overwrite the mergefields in a document created from the template via wordApp.Documents.Add. The article's claim "Word templates are created using MergeField’s in word" is misleading at best; Word templates usually don't contain mergefields and mergefields are usually not found in templates!
If you don't want to save the document, simply replace:
wordDoc.SaveAs("myfile.doc");
wordApp.Documents.Open("myFile.doc");
wordApp.Application.Quit();
with:
wordApp.Application.Quit(False);
If you want Word to remain open, omit wordApp.Application.Quit(False); also
Should replace
With
Now the word that has been merged didn’t require saving at first and it’s just like a draft.