I would like to show some C# source code in a PowerPoint presentation. But how can I copy the code including the syntax highlighting onto the slides? I could make screenshots, but that has some drawbacks (ugly, font size, unmaintainable). Do you have some ideas?
8 Answers
- copy the code from Visual Studio to PowerPoint
- choose "keep original formatting" on the Paste Options icon

- 26,911
- 4
- 71
- 95
-
1Embarassingly I totally missed that feature... ;) Unfortunately, however, the code is randomly colored and needs to be fixed with a load of extra work. – May 06 '09 at 06:33
-
For some reason I only have the option to paste RTF or unformatted. RTF does not preserve black text. – Rick Minerich Jul 09 '09 at 15:43
-
1Oh my god... any idea how many times I've looked for a way to do this! – Walden Leverich Oct 01 '09 at 15:43
-
1Unfortunately it doesn't preserve the original font this way. I tend to use Krogue2's solution using "Paste Special (CTRL+ALT+V)" and then "Formatted Text (RTF)" – riezebosch Aug 26 '11 at 14:41
-
+1 - this doesn't keep the formatting - at least not in PPT 2010. Paste Special with HTML worked well for me. – ScottBai Sep 16 '11 at 04:08
-
FYI, this also works on a Mac when the code (C++ in my case) was copied from XCode (tested with PowerPoint 2011 and XCode 4.6.3) – barbaz Sep 16 '13 at 09:37
-
2When I attempt this from Visual Studio 2013 into PowerPoint 2010, all line breaks are missing, effectively writing all the code as a single, very wide line. If I select *Keep text only*, the line breaks are preserved, but then I lose the formatting :( – Mark Seemann Aug 25 '14 at 16:37
If I copy the code from Visual Studio directly into PowerPoint, using Paste Special (and picking RTF), it only does some of the formatting.
Here is how I got it to do all the formatting.
- Copy the code in Visual Studio. (Ctrl+C)
- Open a new Word document and do a paste. (Ctrl+V)
- Re-select the code in Word and copy it again. (Ctrl+A, Ctrl+C)
- In PowerPoint, do a Paste Special, as "HTML Format". (Ctrl+Alt+V)
"Paste Special" (Ctrl+Alt+V) will do it. This option is available in different places depending on your version of PowerPoint.

- 30,970
- 4
- 37
- 49
-
Unfortunately, this doesn't work at all, at least not in the ordinary text boxes. BTW, we are using Office 2003. Maybe this is new in the 2007 version? – May 06 '09 at 06:27
In Notepad++ 6.9.2 or higher, right click the text and select Plugin Commands
and Copy Text with Syntax Highlighting
.

- 11,557
- 16
- 54
- 68
-
1This is great alternative when you don't want to buy/install visual studio just to prepare a slide show. – OznOg May 09 '17 at 08:49
-
I accept all of the answers posted.
I have found a more presentable way of sharing the code in ppt, which will look elegant in presentation.
use https://carbon.now.sh/ which is free and open source, add your code, do customizations and then export it to add it in ppt.

- 495
- 1
- 8
- 19
- in PPT, click "Insert" -> "Object" -> "Create New" -> "Microsoft Word Document"
- Copy your code to the newly created object in PPT slides,
- You will see the formatting and highlight now.

- 61
- 1
- 1
Copy and paste the code to WordPad, then copy from word pad to wherever you want and keep original formatting

- 549
- 7
- 12
You can use Windows Live Writer with the Insert Code plugin to "write" the C# code and syntax highlight it. This should be copy and pastable directly into PowerPoint, since it's inlines all of the syntax highlighting using styling elements.

- 554,122
- 78
- 1,158
- 1,373