We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to clear content in word document using aspose.words

how to assign oCurrDoc to oDestDoc and clear the content in oCurrDoc.

Hi

Thanks for your request. If you mean append convert of one document to another, then you can use Document.AppendDocument method as described here:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.document.appenddocument.html

If you need to remove all content of the document, you can try using code like the following:

Document doc = new Document(@"Test001\in.doc");

// Remove everything from the document

doc.RemoveAllChildren();

// Ensure minimum to make the document valid. This will insert one empty section with one empty pragraph.

doc.EnsureMinimum();

doc.Save(@"Test001\out.doc");

Hope this helps.

Best regards,

i dont want to save at last..just i want to clear the in.doc itself.

actually my requirement is i have to assign current document content to destination document and next i have to clear the content in current document..............

is it the right way to check

Document srcdoc = new Document(@"C:\test.docx");//--current

Document dstdoc = new Document(@"C:\blank.docx");//--Dest

dstdoc.AppendDocument(srcdoc, ImportFormatMode.KeepSourceFormatting);--assigning content from current to dest

string content = dstdoc.Range.Text ;--getting content in destination

srcdoc.RemoveAllChildren();--clearing content in current

string clearcon = srcdoc.Range.Text;

Hi

Thanks for your request. I saved the document only for testing. If you do not need to same do not do this.

Best regards,

u didnt gave reply to my question

is it the right way to check it

is it the right way to check

Document srcdoc = new Document(@"C:\test.docx");//--current

Document dstdoc = new Document(@"C:\blank.docx");//--Dest

dstdoc.AppendDocument(srcdoc, ImportFormatMode.KeepSourceFormatting);--assigning content from current to dest

string content = dstdoc.Range.Text ;--getting content in destination

srcdoc.RemoveAllChildren();--clearing content in current

string clearcon = srcdoc.Range.Text;

Hi

Thanks for your request. Yes, your code is correct.

Best regards,