Search code examples
c#ms-wordformattingformat

How to copy code from Visual Studio to MS Word with EVERY highlight exactly as it is?


I am making a report about my program and I need copy all the code to an MS document. The problem is that I need to keep every colour as it is. I've tried using Notepad++ for this and online converters but it didn't seem to work as some colours got lost. For example if I have something like this:

public void SomeFunc(String someArg){}

The type "String" seems to lose its colour (the language is C# btw). I also don't want static images in the document (like screenshots of the code or when using the "Insert object" method in MS Word). Is there any way to accomplish this?


Solution

  • So I was looking for an answer to this and this is what i found. Go to Extensions (manager) -> look for: Productivity Power Tools -> install & restart VS. Now when i copy/paste from VS to Word, literally all syntax colors are being copied over 1:1. even the background color is matched.

    I use VS 2019 preview these days.