views:

275

answers:

5

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?

+4  A: 

http://www.planetb.ca/2008/11/syntax-highlight-code-in-word-documents/

darlinton
Great link! I would +1 if my up vote isn't already capped.Just to add to the site's IE comments, Google Chrome works too!
Xavier Ho
A: 

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.

RichieHindle
A: 

If you have Eclipse CDT or Visual around they do it automatically for you when you paste code to Word (Or similiar). I assume it's not best solution for a gvim guy, but still. Just so you'll know.

Shiroko
A: 

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)

ArunSaha
A: 

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.

Vitali Climenco