If you like to write your developer documentation in Word documents, you will surely want to write code snippets for examples away more often. Copy and paste from the development environment usually works quite well, syntax highlighting remains the same.
The only bad thing is that Microsoft quickly starts to rampage in formatting, especially when cross-document formatting is applied.
A wrong heel, a bad enter and the snippet is destroyed and has to be pushed together again with great effort. And two paragraphs later, the same problem…
Attention: this solution is tested in Microsoft Word with german language. Some buttons or textes may differ in the english version.
However, a very simple solution with board means is offered here. No extensions, just plain office. You proceed as follows:
- open the tab “insert”
- far right you will find the button “Object” with a small black arrow on it
- select OpenDocument-text here, and click OK
- a new Word window opens, in which you now insert your source code
- press save (yes, in the new window) and close the window
That’s it. Now you have a code snippet with syntax and everything in your document. The whole thing is treated like a picture or something similar, so it won’t be torn out of the glue when formatting!
Thats it! Quick and easy.