61

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 Answers8

50
  1. copy the code from Visual Studio to PowerPoint
  2. choose "keep original formatting" on the Paste Options icon
sblom
  • 26,911
  • 4
  • 71
  • 95
  • 1
    Embarassingly 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
  • 1
    Oh my god... any idea how many times I've looked for a way to do this! – Walden Leverich Oct 01 '09 at 15:43
  • 1
    Unfortunately 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
  • 2
    When 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
29

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.

  1. Copy the code in Visual Studio. (Ctrl+C)
  2. Open a new Word document and do a paste. (Ctrl+V)
  3. Re-select the code in Word and copy it again. (Ctrl+A, Ctrl+C)
  4. In PowerPoint, do a Paste Special, as "HTML Format". (Ctrl+Alt+V)
Hulk1991
  • 3,079
  • 13
  • 31
  • 46
Krogue2
  • 291
  • 3
  • 4
13

"Paste Special" (Ctrl+Alt+V) will do it. This option is available in different places depending on your version of PowerPoint.

Ishmael
  • 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
8

In Notepad++ 6.9.2 or higher, right click the text and select Plugin Commands and Copy Text with Syntax Highlighting.

Roberto
  • 11,557
  • 16
  • 54
  • 68
  • 1
    This 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've tried this but it doesn't work. PowerPoint 2016 and notepad ++ 7.1. – Cho Aug 14 '19 at 01:28
7

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.

enter image description here

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

Copy and paste the code to WordPad, then copy from word pad to wherever you want and keep original formattingkeepOriginalFormatting

Jaad Chacra
  • 549
  • 7
  • 12
1

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.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373