This is just a simple working example to access all Text Frames in a document.
Of course you might want to do something with it so I did not stop just outputting this but added a lib to create an ODT file.
ODT is part of the Open Document Format family so you can open it with Openoffice and also with MS Word 2007 SP2+.