How to insert code in word and keep the style unchanged
Sometimes we need to add a piece of code to the word, but after we paste the code into the word document, we will find that all the code looks changed, we can use the following method to ensure that the original style and color of the Code are highlighted.
1. This method is suitable for pasting the code in Visual Studio into a Word document.
A. Select the insert tab in word and click the object
B. Select the OpenDocument text in the pop-up window, and a new word window will pop up. copy and paste the code in Visual Studio here and save the closed window.
C. The following
2. This method is completed using notepad ++, and the effect is very good. Other Editors such as sublime should also have similar functions. I have not tried this method yet.
A. open the written code in Notepad ++ and select plugins → nppexport → copy all formats to clipboard. In this way, you can copy and paste the selected code to the word with the original style.
B.
PublicStatic void main()
{
Console.Writeline("Hello World");
Console.Readkey();
}
If the above effect is directly pasted in the word, the word will show the checked spelling errors in a curve, but if we use the above method to insert the object, then execute the paste operation, and we will see the following effect
Reference:
Http://stackoverflow.com/questions/387453/how-do-you-display-code-snippets-in-ms-word-preserving-format-and-syntax-highlig
How to insert code in word and keep the original code style unchanged