How can I programmatically open and save a PowerPoint presentation as HTML/JPEG in C# or Perl?
c#, ole, perl, powerpoint
Solution
The following will open `C:\presentation1.ppt` and save the slides as `C:\Presentation1\slide1.jpg` etc.
If you need to get the interop assembly, it is available under 'Tools' in the Office install program, or you can download it from here (office 2003). You should be able to find the links for other versions from there if you have a newer version of office.
using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
namespace PPInterop
{
class Program
{
static void Main(string[] args)
{
var app = new PowerPoint.Application();
var pres = app.Presentations;
var file = pres.Open(@"C:\Presentation1.ppt", MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
file.SaveCopyAs(@"C:\presentation1.jpg", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoTrue);
}
}
}
Edit: Sinan's version using export looks to be a bit better option since you can specify an output resolution. For C#, change the last line above to:
file.Export(@"C:\presentation1.jpg", "JPG", 1024, 768);
Problem
I am looking for a code snippet that does just this, preferably in C# or even Perl. I hope this not a big task ;)