How to Paste Source Code from Visual Studio into Word without Getting the White Background

Problem: If you copy source code from Visual Studio 2022 and paste it into a Word table, you get an ugly white background behind the text.

Solution: There is absolutely no way to fix this directly because by default, when you copy source code from Visual Studio you can only paste as RTF, not the necessary HTML format. Therefore, you must install the VS Productivity Power Tools from marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.ProductivityPowerPack2022. After the PPP installation, after a Copy, when you do Paste | Paste Special | you get a new option to paste as HTML Format.

Update: I installed Visual Studio 2026 recently. In order to copy-paste without the annoying white from VS2026, you must install the “Copy As Html 2022” extension. See the bottom of this post.



Click To Enlarge


Without the ability to copy/paste using HTML format, there is absolutely no way to avoid the annoying white background on text. Trust me on this, I spent hours investigating.

The common work-around (without installing PPP) is to paste source code from Visual Studio into Visual Studio Code and then copy from VS Code, which allows you to paste as HTML Format. Another work-around is to copy/paste from Visual Studio into Notepad++ with the C# (or whatever) language selected, and then do Plugins | NPP Export | Export to HTML and then paste that into Word.

I rarely use profanity, but WHY THE HECK doesn’t Visual Studio have built in capability to copy as HTML? ARGH!!


For Visual Studio 2026, instead of installing the entire Productivity Power Tools (for VS2022), you can install just the “Copy As Html 2022” extension. In spite of the name, the extension works for VS 2026 too. Open VS 2026. Go Extensions | Manage Extensions | Browse. Type “copy as html” into the search box. You’ll see two extensions — “Copy As Html 2022” from Microsoft DevLabs, and “Copy As HTML” from Tim Mathias. I used the DevLabs version. Install it.

After restarting VS 2026, if you copy code, it’s automatically copied with all formatting. When you paste into Word, do Paste | Paste Special and you’ll get the option to paste as “HTML Format”. Then you can do the shade | Apply To Paragraph, and then shade | Apply to Table as described in the image.

By the way, I noticed that for this technique to work, you have to follow the instructions 1, 2, 3 in the image exactly. Even a slight change makes the copy-paste without annoying white background fail.

This entry was posted in Miscellaneous. Bookmark the permalink.

Leave a Reply