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/
Asked
Active
Viewed 385 times
-2
-
1As it stands, this question is off-topic according to Stack Overflow policy. All code concerned in a question should be *in* the question, not in an outside link. You can use the [edt] link below the question to include the code. – Cindy Meister Sep 19 '18 at 08:41
2 Answers
1
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

macropod
- 12,757
- 2
- 9
- 21
-
Thanks for your answer. Do you have any article that I could use for standard mail merge and absolutely don’t save it and the end? – Seena Fallah Sep 17 '18 at 03:07
-
A true Word mailmerge has three output options: new document, printer, or email. None of these *requires* a document to be saved. I suggest you start with the basics: https://support.office.com/en-us/article/use-mail-merge-for-bulk-email-letters-labels-and-envelopes-f488ed5b-b849-4c11-9cff-932c49474705 . Once you have a handle on that, you can look into automating the merge, if necessary, for which you might review discussions such as: https://social.msdn.microsoft.com/Forums/office/en-US/581e07c4-e0df-424d-b9c5-986cca3eee9b/word-mail-merge-automation – macropod Sep 17 '18 at 06:25
-
If you want Word to remain open, omit wordApp.Application.Quit(False); also. – macropod Sep 17 '18 at 20:55
-1
Should replace
wordDoc.SaveAs("myfile.doc");
wordApp.Documents.Open("myFile.doc");
wordApp.Application.Quit();
With
wordApp.visible = true;
wordApp.Activate();
Now the word that has been merged didn’t require saving at first and it’s just like a draft.

Seena Fallah
- 560
- 4
- 12