Copying code into word document and keeping formatting

user2996828 picture user2996828 · Mar 27, 2014 · Viewed 84.5k times · Source

I need to get my code (Python 2.7 written in the Python IDE) into a word document for my dissertation but I am struggling to find a way of copying it in and keeping the formatting, I've tried paste special and had no luck. The only way I've found so far is screenshoting but with just over 1000 lines of code this is proving very laborious.

Answer

user2996828 picture user2996828 · Apr 1, 2014

After trying every method I still had problems then came across this!, basically copy and paste your code and select what language it is (e.g. python, java, ...), and it will kick out the formatted and coloured version ready to be pasted into word :-)

Code to Word and keep formatting