How to Paste Code into MS Word with Formatting?

How to Paste Code in MS Word with Formatting

In this article, we’ll see how to paste code into Microsoft Word with formatting.

First, open MS Word, click on the “Insert” tab, and insert a 1X1 table.

ms word insert table

Next, select the table and click on the “Cell Shading” option. It changes the background color of the table. Choose a black color.

table cell color

Next, copy your code from the IDE. I am copying the Python code.

copy code ide

Next, open the Word, click on our table, and press CTRL + V.

code snippet in ms word with formatting

As you can see, the code snippet is pasted with formatting. Those red color underlines are because of the spell-checking features of the Word. You can disable it if you want.

This is a simple trick to paste code into MS Word with formatting. I hope you find it useful. If you have any doubts, comment below.


Leave a Comment