OfficeTips Home || VBA Section || General Section ||  Download Section  ||  Privacy Policy

Scripting Example to Export a PowerPoint Presentation as JPEGs

  This example illustrates the use of Windows Scripting Host to automate the process of creating JPEGs of the slides in a PowerPoint presentation. You will need to copy the code below into a notepad file and ensure that you save it with a .VBS extension.

' --------------------------------------------------------------------------------
' Copyright 1999-2014, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------

MessageText    = "Script to open a PowerPoint Presentation and Export as JPEGs."
TitleText      = "PowerPoint Scripting Example"
Call Welcome()
Dim oPPT
Dim oPPTDoc
Dim sPath
Dim sOutput
sPath= InputBox("Enter the path to the file:",TitleText )
sOutput= InputBox("Enter the path to export JPEGs to:",TitleText )
Set oPPT = WScript.CreateObject("PowerPoint.Application")
' You can comment the line below to keep PowerPoint hidden.
oPPT.Visible = TRUE
Set oPPTDoc=oPPT.Presentations.Open(sPath,,,False)
oPPTDoc.Export sOutput,"JPG"
Set oPPTDoc = Nothing
set oPPT = Nothing
MsgBox "Export complete.",vbInformation+vbOkOnly,TitleText
Sub Welcome()
    Dim iPrompt 
    iPrompt = MsgBox(MessageText, _
                      vbOKCancel + vbInformation, _
                      TitleText )
    If iPrompt = vbCancel Then
    End If
End Sub




Copyright 1999-2014 (c) Shyam Pillai. All rights reserved.