Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 830
Zablas Avatar asked Mar 17 '19 16:03

Zablas


People also ask

How do I copy color syntax highlighted code into word?

To copy color syntax highlighted code into Word, copy your selected code from VS Code and paste it into Word. If you are using the “Light (Visual Studio)” theme, the result will look something like this:

How can I highlight the code in a document?

A popup will show up: select OpenDocument Text. A new "embedded" document will appear: go to your favourite Developer Framework, such as Visual Studio, Eclipse, Android Studio, Notepad++ or the one doing the highlight the way you want it to be. Copy the code from there and paste it to the new document. Save and close the new document.

Can I copy code from Visual Studio Code to other applications?

In this article, we learn how to copy from Visual Studio Code with color syntax highlighting to various other applications including Word, PowerPoint, Outlook, OneNote, and Gmail to achieve beautiful, clear code samples for documentation, presentations, and general communication.

How to add VS Code to Microsoft Word?

Fill the text box with a background color that matches the VS Code theme. For the “Dark+ (default dark)” theme, for example, the background color is (Red = 30, Green = 30, Blue = 30). Copy the selected code from VS Code and paste it into Word. If we paste it directly to PowerPoint, we lose the tabs/spacing indentation.


1 Answers

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.

like image 164
siggi_pop Avatar answered Sep 23 '22 03:09

siggi_pop