in reply to generating a microsoft word doc
You could consider looking at automating LibreOffice, whacn can save files in Word format. Automating LibreOffice using Perl and UNO.