A relatively good template is required for the graduation project defense recently. Although I have collected thousands of templates, the results of automatic PPT thumbnails are too poor. You need to manually open the templates to view them, very troublesome. Today, I used C # To write a small Program Converts PowerPoint to JPEG and can be used to quickly query PPT, pptx, and pot content. Simple, convenient, and practical. Code A little messy.
Install Office 2007 before that.
PS: the first version of the program forgot P. Close (), that is, closing the current slide, resulting in the final memory usage of 1.5 GB, full running speed, super cold ~~~
Using System;
Using System. Collections. Generic;
Using System. text;
Using System. Windows. forms;
Using System. IO;
Using Microsoft. Office. core;
Using Microsoft. Office. InterOP. PowerPoint;
namespace ppt_to_jpeg
{< br> class Program
{< br> [stathread]
static void main ( string [] ARGs)
{< br> applicationclass AC = New applicationclass ();
String Srcroot;
String Dstroot;
Folderbrowserdialog FBD = New Folderbrowserdialog ();
FBD. Description = " Select root folder " ;
If (FBD. showdialog () ! = Dialogresult. OK) Return ;
Srcroot = FBD. selectedpath;
FBD. Description = " Select destination folder " ;
FBD. shownewfolderbutton = True ;
If (FBD. showdialog () ! = Dialogresult. OK) Return ;
Dstroot = FBD. selectedpath;
String [] Pptfiles = Directory. getfiles (srcroot, " *. Ppt " , Searchoption. alldirectories );
String [] Potfiles = Directory. getfiles (srcroot, " *. Pot " , Searchoption. alldirectories );
String [] Pptxfiles = Directory. getfiles (srcroot, " *. Pptx " , Searchoption. alldirectories );
Console. writeline ( " Find " + (
Pptxfiles. getupperbound ( 0 ) + 1 +
Potfiles. getupperbound ( 0 ) + 1 +
Pptxfiles. getupperbound ( 0 ) + 1 ) + " Files " );
Foreach ( String PPT In Pptfiles)
{
String Dir = PPT. substring (srcroot. Length + 1 );
String Fulldir = Path. Combine (dstroot, DIR );
Fulldir = Fulldir. substring ( 0 , Fulldir. Length - 4 );
Directory. createdirectory (fulldir );
Console. writeline ( " Converting PPT file ( " + Fulldir + " ) " );
Presentation P = AC. Presentations. Open (PPT, msotristate. msoctrue, msotristate. msoctrue, msotristate. msofalse );
P. saveas (fulldir, ppsaveasfiletype. ppsaveasjpg, msotristate. msoctrue );
P. Close ();
}
Foreach ( String Pot In Potfiles)
{
String Dir = Pot. substring (srcroot. Length + 1 );
String Fulldir = Path. Combine (dstroot, DIR );
Fulldir = Fulldir. substring ( 0 , Fulldir. Length - 4 );
Directory. createdirectory (fulldir );
Console. writeline ( " Converting pot file ( " + Fulldir + " ) " );
Presentation P = AC. Presentations. Open (pot, msotristate. msoctrue, msotristate. msoctrue, msotristate. msofalse );
P. saveas (fulldir, ppsaveasfiletype. ppsaveasjpg, msotristate. msoctrue );
P. Close ();
}
Foreach ( String Pptx In Pptxfiles)
{
String Dir = Pptx. substring (srcroot. Length + 1 );
String Fulldir = Path. Combine (dstroot, path. getfilename (DIR ));
Fulldir = Fulldir. substring ( 0 , Fulldir. Length - 4 );
Directory. createdirectory (fulldir );
Console. writeline ( " Converting pptx file ( " + Fulldir + " ) " );
Presentation P = AC. Presentations. open2007 (pptx, msotristate. msoctrue, msotristate. msoctrue, msotristate. msofalse, msotristate. msofalse );
P. saveas (fulldir, ppsaveasfiletype. ppsaveasjpg, msotristate. msoctrue );
P. Close ();
}
console. writeline ( " all done, press ENTER key to exit " );
console. readline ();
}< BR >}< br>