Syntax highlighting in MS Word document
Solution 1
I found Notepad++ also can copy the code as .rtf file. Plugin/NppExport/Copy RTF to Clipboard, Then you can paste them into word with highlight and layout.
Solution 2
I've found a tool similar to this found by darlinton, but having several different styles of colouring: http://tohtml.com/. I hope it would help.
Solution 3
You can leverage the syntax highlighter that is in use at StackOverflow. I mean the text area where you add the content to be posted to the site :)
But for a more robust and configurable solution you could check out the syntax highlighter developed by Alex Gorbatchov (link). But well, installing it requires some knowledge of HTML and CSS. So, if I needed a quick solution to format my output, I would opt for planet.ca, as darlinton and ArunSaha.
Solution 4
If you don't mind using a different editor for this job, you could load your code into SciTE, use the Edit / Copy as RTF command, and then paste into Word.
Solution 5
After some more searching, I also found Highlight 2.9. But that requires (a) installing an application, and (b) [subjective] aesthetically I like the output of planetb.ca 's output (the answer provided by darlinton)
Arun
"Programs must be written for people to read, and only incidentally for machines to execute." - Abelson & Sussman
Updated on July 09, 2020Comments
-
Arun almost 4 years
I want to insert some C/C++ source code into a Microsoft Word document. I have no problem in copying the code from source file and pasting into Word. I can do fixed-width. But, in Word, I see the code in black-and-white format; I loose the syntax highlighting as I get in the source code editor (for me, gvim). So, my question is, is there any way to do syntax highlighting of C/C++ source code in MS Word?