Free Support Forum - aspose.com

Not able to replace data containing special characters

I want to replace the data read ,by a new data, but the old data contains some special characters becauase of which i'm not able to replace the old data with new one

I'm getting this data after i read word file which contains special characters and some extra data that is not there in word file (marked in red)

"Computer Generated drawing\rprepared on: ms word / visio\rdataset file name: 826 DOCVARIABLE DwgDes \\* MERGEFORMAT W DOCVARIABLE Bundle \\* MERGEFORMAT 5172s DOCVARIABLE Assy \\* MERGEFORMAT 001A.doc\a"

What can be the solution to replace the data containing special characters?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your inquiry. This text is field codes. I think you should use ToTxt() method instead GetText() method and Range.Text property.

Hope this helps.

Best regards.

thanks, that did work for removing the special characters. But even after removing the special characters m not able to replace that data with new one.
Even if i try to delete (Remove )data and insert new data, m not able to do that. Though it doesnt show any error in code nor throws an exception, but the changes doesnt get reflected in the word file.

Is it some problem with word file where i am trying to make changes?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can’t replace special character. This is by design. An exception is thrown if captured or replacement strings contain one or more special characters: paragraph break, cell break, section break, field start, field separator, field end, inline picture, drawing object, footnote.

Best regards.