map.girl

Import text files into preformatted word document

Discussion created by map.girl on Mar 28, 2013
Latest reply on Apr 25, 2013 by galvine
I have this incredibly long python script that ultimately ends up with several text files (generated using ArcGIS 10.1) that I would like to import into a pre-formatted MS Word document/template. I want the files imported into the document and then displayed within MS Word for review.

Can this be done? And if so, what approaches would you, the python gurus, recommend?

I attached some very small dummy sample files (Lou Gehrig speech for those baseball fans) in hopes that I could get some specific code examples to go by and then modify as I progress through the text file generation scripting process, which is on-going. Let???s assume files are kept in C:\Test. Using python 2.7. MS Word 2007.

Thank you all in advance.

Files included in attachment:

SampleInsertText.docx -  A sample of the MS Word 2007 template
SampleResult.docx - A sample of the resulting word document after scripting
textfile1.txt - sample of 1st paragraph to be imported
textfile2.txt - sample of 2nd paragraph to be imported
textfile2.txt - sample of 3rd paragraph to be imported
textfile2.txt - sample of 4th paragraph to be imported

Attachments

Outcomes