Free Support Forum -

Replace questions

I have two issues/questions in regards to aspose.word.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I’m trying to do a replace of key words (e.g. [Clients_Address]) in a word document and then save the results.

However, I’m finding that the replace only works on certain key words, with the remainder being left unchanged.

Secondly, can you replace text with a table?


The replace feature in Aspose.Word is somewhat limited at the moment. It can only replace text that fits into one text run. We define one text run as a sequence of characters with the same formatting within one paragraph, but MS Word sometimes can break it into multiple runs due to editing operations you perform in the document.

It is not possible to replace text with a table at the moment.

We will improve the replace feature over the next 2-3 months.

In the meantime I suggest you look at using merge fields or bookmarks to achieve what you want, Aspose.Word supports them better. For example you can call DocumentBuilder.MoveToBookmark or MoveToMergeField and then insert any content or formatting there.

The replace feature has been improved in Aspose.Word 3.1 and should allow to achieve what you wanted.