Embed Code Snippets into Microsoft Word with Notepad++

Why Notepad++? Well, Microsoft Word isn’t exactly the first program one might think of when it comes to writing code. While Word can do a lot of things, code editing isn’t what it’s designed for. Nevertheless, writing good documentation for technical processes is a critical function that even coders can’t avoid. And since Microsoft Word is the standard for documents, it’s inevitable you’ll need to at least drop the occasional code snippet into a Word document at some point.

But dropping code into MS Word sucks.

If you’ve made it this far, it’s safe to say you got here looking for a clean way to get your code snips and scripts into a Microsoft Word document. You’d probably even want to retain syntax highlighting right? So let’s get into it…

Using Notepad++

The key to displaying code that looks good starts with the editor you use to write the code. Notepad++ is a great source code editor that supposed syntax highlighting for dozens of languages.

If you write code and scripts, you probably already know Notepad++ but if not, you can get it here.

Once it’s installed, type in your code, pick the language and all the syntax will be highlighted appropriately.

A sample piece of SQL query script auto-highlighted in Notepad++

Notepad++ comes in both 32-bit and 64-bit flavors. I happen to prefer the 64-bit version, but there’s a catch…

Installing the NppExport Plugin

Notepad++ supports a ton of different plugins that give added functionality. You can use the help menu to be taken to Notepad++ Plugin Central but unfortunately, only the 32-bit version of NPPExport is available there.

If you installed the 64-bit version of Notepad++, you’ll need to head over to Github to snag the 64-bit version.

All you need to do is copy the NppExport.dll file from the download and drop it into your Notepad++ plugin directory. Unless you customized your install, it’ll be located at C:\Program Files\Notepad++\plugins.

The next time you open Notepad++, the plugin will be available.

Copying Text and Syntax Highlighting

Now that all the tools are in place, all you need to do is highlight the section of code you want to copy. Right-click the selection and then mouse-over Plugin Commands from the context menu. In the submenu, click Copy Text with Syntax Highlighting.

The selection will be copied exactly as you see it.

Once that’s it, you just paste into Microsoft Word like you normally would and voila! All of your code with its pretty syntax is laid out in your Word document.

Conclusion

Folks in the technology industry spend a good amount of their time writing documentation. With the help of Notepad++ and the NppExport plugin, you can use the industry standard documentation software without sacrificing the syntax of your code snippets.

Sharif Jameel is a business owner, IT professional, runner, & musician. His professional certifications include CASP, Sec+, Net+, MCSA, & ITIL and others. He’s also the guitar player for the Baltimore-based cover band, Liquifaction.

If you found the information in this post to be useful, please consider subscribing up to our email list. There's no spam, we currently only send emails once a month or less.

Sharif Jameel

Sharif Jameel is a business owner, IT professional, runner, & musician. His professional certifications include CASP, Sec+, Net+, MCSA, & ITIL and others. He’s also the guitar player for the Baltimore-based cover band, Liquifaction.