I Opened/Created a new Word document dynamically on FormLoad using:
- using Word = Microsoft.Office.Interop.Word;
- oWord = new Word.Application();
- oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
I have "SAVE BUTTON" that saves the said document using:
- oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
Then I added the syntax for closing the document on FormClosed using:
- oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
Scenario: I Ran my program and closed/exit after. Suddenly a "Save as" dialog for the document popped up. I realized that I haven't saved the document because the saving process is in the "SAVE BUTTON".
How can I scape saving the document or automatically choose "cancel" for saving? Any help folks?