How to Insert Code Snippet in Word

preview_player
Показать описание
How to Insert Code Snippets with Syntax Highlighting

Paste from Microsoft Visual Studio:
The best method is to simply paste from Visual Studio (or your favorite IDE) into an OpenDocument Text Object in Microsoft Word.
1. Copy the code from your IDE with Ctrl+C.
2. Click the Insert tab at the top, then click the Object button.
3. Scroll down the list and click OpenDocument Text and click OK.
4. Hit Ctrl+V to paste the copied code into the newly opened document. There may be tabbing issues because of the margins. Either edit this in your IDE or choose the offending line, hit Enter to return it and then press Tab to line it up. You can also use the Ruler to guide it into place. To view the ruler, open the View tab at the top and check the Ruler box.
5. After ensuring that everyone looks good, click the X at the top-right to close the OpenDocument Text object and to return to editing your main document.

What’s your favorite programming language? Please let us know in comments.

#HowTech #MicrosoftWord
Рекомендации по теме
Комментарии
Автор

it does not work with long code, ones it reaches the size of a page it does not expands to the next page.

adriansuarezdelvillarpomar
Автор

Thanks for this! But is there a way to add object that span more than one page?

KeniWilliams
Автор

Thanks man, saved me for my algo class!

AliMalik-ytex
Автор

I used the Easy Syntax Highlighter Add-on for MS Word, but the way you suggest it is much better. Thanks!

leonidd
Автор

Thanks for the explanation of opendocument text. One thing that escaped me on watching was how to get out of the embedded document. The video said "if we X that out". I couldn't follow what you did. I finally hit the X in the upper right, close window, and all of word minimized, but when I clicked the icon in the taskbar, the main document came back.

edgreenberg
Автор

Spot-on! This is fitting, since my favorite language is C and I mostly use Visual Studio. :)

dvdvideo
Автор

Great this tools iam used for reporting my job.. Thanks!

andrinuka
Автор

this doesnt show up for me on mac on word

avishka-don
Автор

Thank you so much, I got a headache while I was trying to format code with Arabic comments, this technique should work for any mixed left to right and right to left texts

husseinshukri
Автор

One thing to notice is it takes a lot of clicks to create the embedded OpenDocument text. Instead you can record a macro and assign it to a keyboard shortcut. To insert code I simply hit alt-c which runs the macro and ctrl-v to insert the code.

Denbo
Автор

is there a way to include line numbers?

maxsimes
Автор

How to add that in using Spanish language in the orders, please?

hanadaabdelfattah
Автор

Assalamualiku, How are you? I am sharmin . This is my youtube channel " be youtuber" . I am a regular viewers on your channel.
Thanks a lot.

Traveltimesharmin