How to show code snippets in MS Word document as it shows in StackOverflow (scrollbars and gray background)

Here is what I did, first the results:

enter image description here

Go to stackoverflow copy some code, paste it in the word doc, you will get this gray box and etc.

Mark you text and go to:

enter image description here

enter image description here

enter image description here

Then you just write your code in any IDE, and past it into the word doc, mark it and set the style to code. :)


I could not comment on most voted answer for @AeroVTP, my rep is too low. But when you create a style, you can modify it by right clicking and then Modify..

Img 1

Then on bottom left, click on Format -> Border. Then on tab Shading you can select whatever color you want as a background. Hope this clears things up :)

Img 2


In Microsoft Word setup a text box (Insert > textbox) select the "format" tab, go to "fill" and choose the background color, set up a grey background, then use a monospaced font and here is your code-like text!

Here is a link to a Microsoft support page that can drive you better if you need: http://office.microsoft.com/en-gb/word-help/make-the-background-of-a-text-box-invisible-HA010337242.aspx?CTT=1

Fro scrollbars is a little more complicated, but here is someone who found a solution: http://answers.microsoft.com/en-us/office/forum/office_2007-word/i-need-a-textbox-with-a-scroll-bar-in-my-word-form/534ced3f-f202-46b1-a4b4-3ecdabaa6899

From there you can find a lot of usefull guides for text formatting and general MS Word use.