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

Free Support Forum - aspose.com

Expansion and deletion of Sub Documents

The customers of the company that I work for tend to have a large collection of template documents that they use for Mail merging. All of these letters have common components (usually a header and footer) that are the same for all of the documents.

To make these documents manageable master and sub documents are used where the two subdocuments are usually the header and footer while the main body of the template is the master.

My company usually performs Word Automation to expand all sub-documents on the master documents and perform the mail merge process. The usage of the Aspose component will completely ignore all sub documents on the letter template.

Since the customers that use these templates are in the insurance industry the format of these documents can be extremely important so I have had to disable the Aspose integration for several of my company’s customers.

I am not looking for any ability to add sub documents on to documents! However, I do need to mimic the following lines of word automation

If mObjWord.ActiveDocument.Subdocuments.count > 0 Then
mObjWord.ActiveDocument.Subdocuments.Expanded = True
mObjWord.ActiveDocument.Subdocuments.Delete
mObjWord.ActiveDocument.Save
End If

All the above code will do is expand the sub document on the master then delete the sub document. So that will be the two methods that I require:

Expand
Delete

With out the usage of subdocuments all of the letter templates will have to be modified and this will be an extremely large amount of work and the brokers that use these templates will not be very receptive about this request.

I have logged your request to support master-subdocuments in Aspose.Words. We will probably do it later.

Meanwhile, if you are considering using our library to substitute Word Automation I can assist in migrating your application.

Combining different documents and document parts can be easily done with Aspose.Words API. If you attach the sample templates together with the resulting document build by your current implementation then I can compose a demo code illustrating how it can be done with Aspose.Words.

Best regards,

That could prove to be useful. It may be worth pointing out that joining multiple documents together is not a hindrance. The identification and expansion of Sub documents is proving to be difficult. I have attached a document that has a sub document attached to it. Please note that these documents will need to reside in ‘C:\’ in order for the sub documents to work.

Thanks in advance.

Thanks for additional info. I will do research and inform you of the results here in this thread.

Best regards,

I looked at this and decided we are not going to support subdocuments now. Although subdocuments appear as hyperlinks in Microsoft Word, they are not stored as such inside a document. They are stored in some undocumented format that as you understand could take time to support. We will keep this feature on our future task list. Sorry for inconvenience.

Hi,


This is an old thread but since WORDSNET-761 subdocuments ARE supported, the question remains:

How do I acheive the equivalent Word automation of unlinking all the subdocuments using Aspose Word?

Thanks
Massoud

Hi Massoud,


Thanks for your inquiry. Please attach your sample Word document you want to unlink sub-documents from here for testing. We will investigate the issue on our end and provide you more information.

Best regards,

Please find attached a sample.

Hi Massoud,


Thanks for the additional information. Please use the following code to remove all SubDocuments from a Document:

Document doc = new
Document(MyDir + @“Main
Doc 3.docx”
);

foreach (SubDocument subDocument in doc.GetChildNodes(NodeType.SubDocument, true))

subDocument.Remove();

doc.Save(MyDir + @“out.docx”);


I hope, this helps.

Best regards,