Copying code into word document and keeping formatting
Solution 1
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
Solution 2
To fix this, instead of directly copying and pasting, use Insert -> Object -> OpenDocument Text. The second option is to create a style for your code.
user2996828
Updated on June 28, 2020Comments
-
user2996828 almost 4 years
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.