title: How to write code to MS Word using python retaining the formatting?
body: <p>I want to create a MS word document which compiles a lot of my existing codes ( in MATLAB and Python). I was writing it using python-docx.</p>
  <p>If I do something like:</p>
  <pre><code>file = open('task1.m', 'r')
  document.add_paragraph(file)
  </code></pre>
  <p>Then the code gets written in MS word in simple text format without the formatting.</p>
  <p>Is there some way I can write the code while retaining the programming language formatting? (Keeping the colors intact)</p>