Free Support Forum - aspose.com

Show doc. before saving

Think about a case :

Document doc = new Document("template.doc");

DataSet ds = DataHelper.GetData("data");

doc.MailMerge.Execute(ds.Tables[0]);

Now mail merge is completed and its ready to save but before saving I want to show the user auto-generated doc - prepared by Aspose.Words, the user may edit auto-generated doc before it is saved

Although I can save temporarily and open doc from this temp location and show but I think it is not a feasible solution

how can I do this ?

Well in theory it should go like this:

  1. Your application notifies the user that the document for him is ready.
  2. User opens the document, edits and saves it.
  3. User notifies your application that he is done with the document.
  4. Your application takes document for further processing.

Ideally it would be nice if your app was automatically notified of user saving the document. There is a .NET class called FileSystemWatcher that can be used to monitor file activity on the system. I have tested it and found that, unfortunately, it fails to track MS Word file open/save activity properly. So we are left with manual user notification, like 'Submit' button or something like that.

As it is said in second item the user opens the document , edits and saves it.

But I mean that I created a Document by using Aspose and before saving I want to show the user and let him to edit and then save.

But aspose opens/shows only saved files. I just want to show created document by Aspose to the user after generation process is finished and a software or the user may save file.

I think aspose should has a method or something like that opens a document without saving. At the end of document generation process you could not show the document to user

But as you probably know Aspose.Words does not have visual representation capabilities of its own. And MS Word needs document file to be able to open it.

To make it more clear let me write a little code;

Document doc = new Document("template.doc");

DataSet ds = DataHelper.GetData("data");

doc.MailMerge.Execute(ds.Tables[0]);

// Now merging of data is completed

// At this point now I want to show merged document to the user ,is it possible ?

// Indeed I can do as follows

doc.Save("result.doc");

Aspose.Word.Word w = new Word();

w.Open("result.doc");

// But in this case if the user ignores the document I have to track and remove document ?

// If I can show the document to the user without saving even temporarily if the user closes MS-Word it is removed from the system.

// I mean I want to show the document in MS-Word without saving temporarily after merge operation is completed

I am afraid there is no way you can show the document generated by Aspose in MS Word without saving to a temporary file.