How do I 'clear' or reset the instantiated Builder?

I build and save the Word output file in a VB.NET subroutine. At the end of the subroutine, I set MainDocument = Nothing and MainBuilder = Nothing.

Yet, when I call the routine again, this time with a different output, it duplicates the first output. That is, the first Word output is apparently still in memory, even though I re-instantiate all objects at the beginning of the subroutine.

It's as if the .DLL remembers the output irrespective of VB.NET calls.

I looked for a MainDocument.Clear or MainBuilder.Clear (or some such equivilant). How do I tell Aspose.Word to flush the just-saved-to-file Word document from memory?

Robert Keller

If you really want to delete everything from the document you can call Document.RemoveAllChildren.

The problem with the same output sounds like you are using mail merge and using mail merge more than once on the same document. Do you use mail merge? The point is that mail merge replaces the merge fields in the document with data. If you attempt another mail merge into that Document object, nothing will happen because there are no more merge fields in it. This will manifest itself as same output. If you want to mail merge again, you need to open the template document again.