Skip to content

Highlighting source code in Word and PowerPoint

File this under “how did I not already know this.”

I put together quite a few PowerPoints and Word documents explaining how to do labs. And since I teach computer science, many of these include source code of some type.

Normally I just type it in and change the font to Courier New or Lucida Sans, which works okay. But syntax highlighting would make everything easier to follow; it’s just been more effort to highlight each section individually that I’ve always left the text black. Thanks to this post I found a much easier way to get it working.

The key is a plugin in Notepad++ called NppExport.

First thing to do is type your code into Notepad++, making sure the language you’re using is selected. The example here is Python, but anything that Notepad++ can highlight will work.

Sample Python code
A bit of Python code

Next, go to the Plugins menu and select NppExport -> Copy all formats to clipboard.

Screenshot of NppExport
Menus to get to NppExport

Then it’s just a matter of going to Word, PowerPoint, or whatever program you want and paste it in.

NppExport will also allow you to both copy and save as RTF and HTML as well.

Published inProgramming

One Comment

  1. Tony Duarte Tony Duarte

    This tip almost worked perfectly for me…when I used “copy all formats” I was given 3 paste options in PowerPoint — all three messed up the formatting in different ways.

    But when I exported using only “Copy RTF to clipboard” I was able to get the syntax-highlighted code into PowerPoint. I know that doesn’t make any sense — but that is how I got it to work.


Leave a Reply

Your email address will not be published. Required fields are marked *