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…(read more)
Convert Word 2 PDF: Word to PDF Converter
Convert PowerPoint 2 PDF: PPT to PDF Converter
Convert Excel 2 PDF: Excel to PDF Converter
Convert an Image 2 PDF: Image to PDF Converter
Convert HTML 2 PDF: HTML to PDF Converter
More Tools: PDF Converter
is there a way to include line numbers?
I used the Easy Syntax Highlighter Add-on for MS Word, but the way you suggest it is much better. Thanks!
nonsense
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.
does not work now
Thank you so much!
this doesnt show up for me on mac on word
Great this tools iam used for reporting my job.. Thanks!
how do I add number line to it ?
Thanks for this! But is there a way to add object that span more than one page?
Very helpful
Does it matter what language you use?
I found very attractive way of doing it very easily. checkout this link here https://www.youtube.com/watch?v=W7CdXThF9OQ&ab_channel=Tecno-Tab
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
Spot-on. I saw that on StackOverflow before ( https://stackoverflow.com/a/2653406 ) but it is nice to have a video support for muppets.
How to add that in using Spanish language in the orders, please?
it does not work with long code, ones it reaches the size of a page it does not expands to the next page.
Thanks man, saved me for my algo class!
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.
Spot-on! This is fitting, since my favorite language is C and I mostly use Visual Studio. 🙂
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.