We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

How to export powerpoint slides to pictures?

ed_dalian
ed_dalian asked
on
Medium Priority
1,000 Views
Last Modified: 2012-06-21
I am working on a c# app, and I want to use my app to read a powerpoint file, and than export them into pictures that the pictures' name is the ppt's page title name so that I can use the picutures. Please help me !!
Comment
Watch Question

Author

Commented:
I want it on powerpoint 2003
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Export what into pictures?  The slides?

Bob
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:

Author

Commented:
Yes, I want more people could see it, so that I could get more help, please help me.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
First of all, it is just confusing if I see the same question twice.  It is recommended to only ask the question once, and then add a "pointer" question.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
Here is a class to work with PowerPoint:

// 1) Add a COM reference to the Micro$oft PowerPoint 11.0 type library.
// 2) Add a COM reference to the Micro$oft Graph 11.0 type library.

using System;
using System.Drawing;
using Microsoft.Office.Interop;
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
using System.Runtime.InteropServices;
using System.Reflection;

public enum SaveAsType
{
  AddIn = PpSaveAsFileType.ppSaveAsAddIn,
  BMP = PpSaveAsFileType.ppSaveAsBMP,
  Default = PpSaveAsFileType.ppSaveAsDefault,
  EMF = PpSaveAsFileType.ppSaveAsEMF,
  GIF = PpSaveAsFileType.ppSaveAsGIF,
  Html = PpSaveAsFileType.ppSaveAsHTML,
  HtmlDual = PpSaveAsFileType.ppSaveAsHTMLDual,
  HtmlV3 = PpSaveAsFileType.ppSaveAsHTMLv3,
  JPG = PpSaveAsFileType.ppSaveAsJPG,
  MetaFile = PpSaveAsFileType.ppSaveAsMetaFile,
  PNG = PpSaveAsFileType.ppSaveAsPNG,
  RTF = PpSaveAsFileType.ppSaveAsRTF,
  TIF = PpSaveAsFileType.ppSaveAsTIF,
  Presentation = PpSaveAsFileType.ppSaveAsPresentation
}

public class PowerPointPresentation
{

  private Application _app = new Application();
  private Presentation _presentation;
  private Slide _slide;

  ~PowerPointPresentation()
  {
    _app.DisplayAlerts = PpAlertLevel.ppAlertsNone;
    _presentation.Close();
    _app.Quit();
    Marshal.ReleaseComObject(_slide);
    Marshal.ReleaseComObject(_presentation);
    Marshal.ReleaseComObject(_app);
    _slide = null;
    _presentation = null;
    _app = null;
  }

  public bool ApplicationVisible
  {
    get { return (_app.Visible == MsoTriState.msoTrue);
    }
    set
    {
      if (value)
      {
        _app.Visible = MsoTriState.msoTrue;
      }
      else
      {
        _app.Visible = MsoTriState.msoFalse;
      }
    }
  }

  public void OpenPresentation(string fileName)
  {
    if (_app == null)
    {
      throw new ArgumentNullException("Application not initialized");
    }
    _presentation = _app.Presentations.Open(fileName,
      MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
  }

  public void SelectSlide(int index)
  {
    _slide = this.GetSlide(index);
  }

  public void SaveAs(string fileName)
  {
    this.SaveAs(fileName, SaveAsType.Presentation);
  }

  public void SaveAs(string fileName, SaveAsType type)
  {
    _presentation.SaveAs(fileName, (PpSaveAsFileType)type, MsoTriState.msoFalse);
  }

  public Slide GetSlide(int index)
  {
    if (_presentation == null)
    {
      throw new ArgumentNullException("Presentation not open");
    }
    if (index < 1 || index > _presentation.Slides.Count)
    {
      throw new ArgumentOutOfRangeException("Out of range", "Slide");
    }
    return _presentation.Slides[index];
  }

}

Bob

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Example:

  PowerPointPresentation pps = new PowerPointPresentation();
  pps.OpenPresentation(@"C:\Temp\Presentation1.ppt");
  pps.SaveAs(@"C:\Temp\Presentation.jpg", SaveAsType.JPG);

Bob

Author

Commented:
TheLearnedOne , Thank you very much!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.