Kalix Diona
Kalix Diona

Reputation: 479

C# Skip/Cancel Saving the Opened Word Document

I Opened/Created a new Word document dynamically on FormLoad using:

I have "SAVE BUTTON" that saves the said document using:

Then I added the syntax for closing the document on FormClosed using:

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?

Upvotes: 0

Views: 1362

Answers (2)

Jason Shuler
Jason Shuler

Reputation: 399

Set the property oDoc.Saved to true. Then Word will not prompt to save when the document is closed

Upvotes: 0

Tim Copenhaver
Tim Copenhaver

Reputation: 3302

The Close method includes a parameter for whether changes should be saved. Just pass wdDoNotSaveChanges as the first parameter. See the documentation for the Close method for details.

Upvotes: 6

Related Questions