Sep 03, 2012 06:16 AM|Jure.Les|LINK
Maybe a better approach would be using Content Controls or at least Merge Fields as placeholders (containg findText). Then, instead of doing text Find/Replace, you would get all these placeholders, loop through them and replace each one with the corresponding
text. If the text contained by such a placeholder was formatted (and the replacing mechanism done right) the final text would retain the format/styles.
Btw., don't use COM as a solution in ASP.Net applications. This is strongly discouraged by Microsoft. Your solution might work and perform fine in a development enviroment but in production enviroment you will have problems almost for sure.
I recommend you to check this product. It does exactly what you need in a safe and user friendly way. At least you might get the idea for your own solution - so take a look at it.
If you really want to create your own document generation solution use Microsoft's Open XML SDK.