Posted By: Anonymous
Does anyone know a way to display code in Microsoft Word documents that preserves coloring and formatting? Preferably, the method would also be unobtrusive and easy to update.
I have tried to include code as regular text which looks awful and gets in the way when editing regular text. I have also tried inserting objects, a WordPad document and Text Box, into the document then putting the code inside those objects. The code looks much better and is easier to avoid while editing the rest of the text. However, these objects can only span one page which makes editing a nightmare when several pages of code need to be added.
Lastly, I know that there are much better editors/formats that have no problem handling this but I am stuck working with MS word.
Here is the best way, for me, to add code inside word:
- go to
objectbutton (it’s on the right)
OpenDocument Textwhich will open a new embedded word document
- copy and paste your code from Visual Studio / Eclipse inside this embedded word page
- save and close
The result looks very nice. Here are the advantages of this method:
- the code keeps its original layout and colors
- the code is separated from the rest of the document, as if it was a picture or a chart
- spelling errors won’t be highlighted in the code (this is cool !)
And it takes only few seconds.