Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am writing a document which intends to show code changes made in C# project, I am looking for a good format to show code snippet.

I like is the way StackOverflow site shows code snippet in its Questions and Answers (scrollbars and background color).

Can anybody guide me to create similar background/view to show code snippet in word document (mainly scrollbars).

I tried copying and pasting it from StackOverflow but the background does not appear.

I search and found this useful link but it does not change background color and don't have scroll bars How do you display code snippets in MS Word preserving format and syntax highlighting?

like image 826
Imran Rizvi Avatar asked Nov 21 '13 11:11

Imran Rizvi


2 Answers

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. :)

like image 144
USer22999299 Avatar answered Sep 28 '22 00:09

USer22999299


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

like image 35
Sotiris Koukios-Panopoulos Avatar answered Sep 28 '22 01:09

Sotiris Koukios-Panopoulos