Open txt and rtf files


From Jat:

Just curious - can you load .rtf & .txt documents as you do with typical Word Automation.

If you can’t, perhaps you can improve the Exception - i.e.

maindoc = word.Open(“C:\temp\test.txt”)
Run-time exception thrown : System.Exception - C:\temp\test.txt already exists maindoc = word.Open(“C:\test.rtf”)
Run-time exception thrown : System.Exception - C:\test.rtf already exists

I.e. it says it already exists (which it does), but maybe it should say ‘Unrecognised format’. Just an idea anyway.


Hi Jat,

We plan to support rtf files loading and saving. Not immediately, but ballpark estimate is around 2 months from now. We will also support html reading and writing and WordML XML format.

Aspose.Word can save in txt format right now. Interesting idea about opening txt files. How would you have your mail merge fields or bookmarks defined in the source text files?

The exception that you came across is thrown by structured storage code (part of Windows), not Aspose.Word directly and I agree it obviously can be improved. We will address this in the future versions.