Is there a way to copy code from visual studio (C#) and paste it into OneNote, without losing the formatting?
I was able to do this, but only if I copy from VS, paste to Word, copy from Word, and then paste to OneNote.
Is there a way to copy code from visual studio (C#) and paste it into OneNote, without losing the formatting?
I was able to do this, but only if I copy from VS, paste to Word, copy from Word, and then paste to OneNote.
You have hit the nail on the head on the process. The application that you are pasting to must be able to accept the code with the formatting properly. MS Word is one of the few that handles this properly, therefore, going from VS -> Word -> OneNote will work. But VS -> OneNote doesn't work.
There is an add-in for Microsoft Visual Studio that allows you to copy source code, syntax highlighting, and line numbers as HTML.
With this add-in, you can copy from VS and paste HTML directly to your target.
Check it out here: CopySourceAsHtml
There is fortunately a solution for Visual Studio 2010! Install the Visual Studio 2010 Pro Power Tools extension and copy/paste to OneNote retains syntax highlighting. Made me a happy man;)
Jan Roelof