Display a Code snippet in Word

This short post will help you display code snippets in MS Word preserving format and syntax highlighting?

There are more ways, but this is the best way for me to add a code snippet:

Go to Insert tab, Text section, click Object button (it’s on the right side)
Choose OpenDocument Text which will open a new embedded word document
Copy and paste your code from Visual Studio / Eclipse inside this embedded word page
Save and close

Advantages

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 !)

Posted in public.

Leave a Reply