How to use export function to export the slides to jpeg?

A

Ade

Hi everyone,

I tried using this:
PowerPoint.Application app = new PowerPoint.Application();
PowerPoint.Presentation pPpx;
pPpx = app.Presentations.Open("C\\temp\temp.ppt",
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse);

for (int i = 0; i < pPpx.Slides.Count; i++)
{
pPpx.Slides.Export("C:\\temp\\ + "lslide" + i + ".JPG", "JPG", 800, 600);
}

But it won't work...anyone can enlighten me??

ade
 
A

Ade

Hi everyone,

I managed to solve it by saving the whole presentation instead of saving by
slides, but still achieved by converting each slide into jpg. Not too sure
why the previous one is not able to work.

string exportPath;

PowerPoint.Application app = new PowerPoint.Application();
app.WindowState = PowerPoint.PpWindowState.ppWindowMinimized;
app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
PowerPoint.Presentation pPpx;
pPpx = app.Presentations.Open(localFileName,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoTrue);

exportPath = pPpx.Path;
pPpx.SaveAs(exportPath,
Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG,
Microsoft.Office.Core.MsoTriState.msoTrue);

pPpx.Close();
app.Quit();

ade
 
S

Steve Rindsberg

I work in VBA so I'm not familiar with the syntax you're using but it appears
that this might have several problems:

pPpx.Slides.Export("C:\\temp\\ + "lslide" + i + ".JPG", "JPG", 800, 600)

1- Shouldn't "C:\\temp\\ be closed with another set of quotes, making it:

pPpx.Slides.Export("C:\\temp\\" + "lslide" + i + ".JPG", "JPG", 800, 600)

2- Does the + operator permit combining strings and integers this way or would
you need to convert i to a string first?

I tried using this:
PowerPoint.Application app = new PowerPoint.Application();
PowerPoint.Presentation pPpx;
pPpx = app.Presentations.Open("C\\temp\temp.ppt",
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse);

for (int i = 0; i < pPpx.Slides.Count; i++)
{
pPpx.Slides.Export("C:\\temp\\ + "lslide" + i + ".JPG", "JPG", 800, 600);
}

But it won't work...anyone can enlighten me??

ade
 
A

Ade

Hi steve,

Thanks for pointing out :) This syntax is C#. It is the new language
supported by .net.

Sorry, I typed it wrongly from my codes, I should have copied and paste it
here.

pPpx.Slides.Export("C:\\temp\\" + "lslide" + i.toString() + ".JPG",
"JPG", 800, 600);

It still returns the same, so I use:
pPpx.SaveAs(exportPath,
Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG,
Microsoft.Office.Core.MsoTriState.msoTrue);

ade

Steve Rindsberg said:
I work in VBA so I'm not familiar with the syntax you're using but it appears
that this might have several problems:

pPpx.Slides.Export("C:\\temp\\ + "lslide" + i + ".JPG", "JPG", 800, 600)

1- Shouldn't "C:\\temp\\ be closed with another set of quotes, making it:

pPpx.Slides.Export("C:\\temp\\" + "lslide" + i + ".JPG", "JPG", 800, 600)

2- Does the + operator permit combining strings and integers this way or would
you need to convert i to a string first?

I tried using this:
PowerPoint.Application app = new PowerPoint.Application();
PowerPoint.Presentation pPpx;
pPpx = app.Presentations.Open("C\\temp\temp.ppt",
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse);

for (int i = 0; i < pPpx.Slides.Count; i++)
{
pPpx.Slides.Export("C:\\temp\\ + "lslide" + i + ".JPG", "JPG", 800, 600);
}

But it won't work...anyone can enlighten me??

ade


--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
S

Steve Rindsberg

Hi steve,

Thanks for pointing out :) This syntax is C#. It is the new language
supported by .net.

Sorry, I typed it wrongly from my codes, I should have copied and paste it
here.

pPpx.Slides.Export("C:\\temp\\" + "lslide" + i.toString() + ".JPG",
"JPG", 800, 600);


There must be some tiny little syntax problem causing this not to work; it looks
very close to what we'd use in VBA:

Call pPpx.Slides(i).Export("C:\Temp\" & "lslide" & Cstr(i) & ".JPG", "JPG", 800,
600)

i is a VBA Long (an integer in C#, I think)
Also the 800 and 600 should be VBA Longs. Is it possible that they're internally
represented in some other way and need to be coerced to VBA Longs/C# Integers when
you call Export? Give that a try.

Do you get any error messages?

It still returns the same, so I use:
pPpx.SaveAs(exportPath,
Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG,
Microsoft.Office.Core.MsoTriState.msoTrue);

ade

Steve Rindsberg said:
I work in VBA so I'm not familiar with the syntax you're using but it appears
that this might have several problems:

pPpx.Slides.Export("C:\\temp\\ + "lslide" + i + ".JPG", "JPG", 800, 600)

1- Shouldn't "C:\\temp\\ be closed with another set of quotes, making it:

pPpx.Slides.Export("C:\\temp\\" + "lslide" + i + ".JPG", "JPG", 800, 600)

2- Does the + operator permit combining strings and integers this way or would
you need to convert i to a string first?

I tried using this:
PowerPoint.Application app = new PowerPoint.Application();
PowerPoint.Presentation pPpx;
pPpx = app.Presentations.Open("C\\temp\temp.ppt",
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse);

for (int i = 0; i < pPpx.Slides.Count; i++)
{
pPpx.Slides.Export("C:\\temp\\ + "lslide" + i + ".JPG", "JPG", 800, 600);
}

But it won't work...anyone can enlighten me??

ade


--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top