PowerPoint to JPEG Convertor

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.