PPT2ANY转换工具

PPT2ANY.vbs

Option Explicit

PPT2ANY "PATH_TO_INFILE\NEOHOPE.COM.IN.pptx","PATH_TO_INFILE\NEOHOPE.COM.OUT.pdf","PDF"
PPT2ANY "PATH_TO_INFILE\NEOHOPE.COM.IN.pptx","PATH_TO_INFILE\NEOHOPE.COM.OUT.png","PNG"

Sub PPT2ANY( inFile, outFile, outFormat)
	Dim objFSO, objPPT, objPresentation, pptFormat

	Const ppSaveAsAddIn                             =8
	Const ppSaveAsBMP                               =19
	Const ppSaveAsDefault                           =11
	Const ppSaveAsEMF                               =23
	Const ppSaveAsExternalConverter                 =64000
	Const ppSaveAsGIF                               =16
	Const ppSaveAsJPG                               =17
	Const ppSaveAsMetaFile                          =15
	Const ppSaveAsMP4                               =39
	Const ppSaveAsOpenDocumentPresentation          =35
	Const ppSaveAsOpenXMLAddin                      =30
	Const ppSaveAsOpenXMLPicturePresentation        =36
	Const ppSaveAsOpenXMLPresentation               =24
	Const ppSaveAsOpenXMLPresentationMacroEnabled   =25
	Const ppSaveAsOpenXMLShow                       =28
	Const ppSaveAsOpenXMLShowMacroEnabled           =29
	Const ppSaveAsOpenXMLTemplate                   =26
	Const ppSaveAsOpenXMLTemplateMacroEnabled       =27
	Const ppSaveAsOpenXMLTheme                      =31
	Const ppSaveAsPDF                               =32
	Const ppSaveAsPNG                               =18
	Const ppSaveAsPresentation                      =1
	Const ppSaveAsRTF                               =6
	Const ppSaveAsShow                              =7
	Const ppSaveAsStrictOpenXMLPresentation         =38
	Const ppSaveAsTemplate                          =5
	Const ppSaveAsTIF                               =21
	Const ppSaveAsWMV                               =37
	Const ppSaveAsXMLPresentation                   =34
	Const ppSaveAsXPS                               =33

	' Create a File System object
	Set objFSO = CreateObject( "Scripting.FileSystemObject" )

	' Create a PowerPoint object
	Set objPPT = CreateObject( "PowerPoint.Application" )

	With objPPT
		' True: make PowerPoint visible; False: invisible
		.Visible = True
 
		' Check if the PowerPoint document exists
		If not( objFSO.FileExists( inFile ) ) Then
			WScript.Echo "FILE OPEN ERROR: The file does not exist" & vbCrLf
			' Close PowerPoint
			.Quit
			Exit Sub
		End If
 
		' Open the PowerPoint document
		.Presentations.Open inFile
 
		' Make the opened file the active document
		Set objPresentation = .ActivePresentation
 
		If StrComp(Ucase( outFormat ),"PDF") = 0 then
			pptFormat = ppSaveAsPDF 
		ElseIf StrComp(Ucase( outFormat ),"XPS") = 0 then
			pptFormat = ppSaveAsXPS
		ElseIf StrComp(Ucase( outFormat ),"BMP") = 0 then
			pptFormat= ppSaveAsBMP
		ElseIf StrComp(Ucase( outFormat ),"PNG") = 0 then
			pptFormat= ppSaveAsPNG
		ElseIf StrComp(Ucase( outFormat ),"JPG") = 0 then
			pptFormat= ppSaveAsJPG
		ElseIf StrComp(Ucase( outFormat ),"GIF") = 0 then
			pptFormat= ppSaveAsGIF
		ElseIf StrComp(Ucase( outFormat ),"XML") = 0 then
			pptFormat= ppSaveAsOpenXMLPresentation
		ElseIf StrComp(Ucase( outFormat ),"RTF") = 0 then
			pptFormat= ppSaveAsRTF
		Else
			WScript.Echo "FILE FORTMART ERROR: Unknown file format" & vbCrLf
			' Close PowerPoint
			.Quit
			Exit Sub
		End If

		' Save in PDF/XPS format
		objPresentation.SaveAs outFile, pptFormat
 
		' Close the active document
		objPresentation.Close
 
		' Close PowerPoint
		.Quit
	End With
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

*