How to export PPT images with slide names instead of numbers?

B

Bon4ire

I'm trying to create a bunch of images from a sequence of slides in
PPT. I know I can save as JPGs for all slides, but it saves it under
one folder as a sequence. What I want to do save with the title name of
the slide.

Each slide has a name like Cat, Dog, Tiger, etc. and want it to save as
Cat.jpg, Dog.jpg, Tiger.jpg etc.

How does one go about doing this? I searched all over the net but
found nothing. The only thing is saw was to save each individual slide
by itself from which the filename will inherit the the slide name. But
it's too tedious epecially with a bunch of animal names.

Thanks
 
C

Chirag

The following macro will save the slides as JPGs in your home folder
(usually, "C:\Documents and Settings\<username>\"). It uses the slide titles
for the file names.

---
Sub ExportSlidesWithTitlesAsFileNames()
Dim Pres As Presentation
Dim Sld As Slide
Dim FilePath As String
Dim FileName As String

Set Pres = ActivePresentation
FilePath = Environ("HOMEDRIVE") + Environ("HOMEPATH") + "\"
For Each Sld In Pres.Slides
FileName = ""
If Sld.Shapes.HasTitle Then
If Sld.Shapes.Title.HasTextFrame Then
If Sld.Shapes.Title.TextFrame.HasText Then
FileName = Sld.Shapes.Title.TextFrame.TextRange.Text
End If
End If
End If
If FileName = "" Then
FileName = Sld.Name
End If
FileName = FileName + ".jpg"
Sld.Export FilePath + FileName, "jpg"
Next
End Sub
---

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
B

Bon4ire

Thanks Chirag and Steve for replying so quickly! Worked like a charm!
I did run across one problem, and that was when I had an animal name
with a question mark. The macro errors on a '?' but not on a '!'. How
would I modify the macro to subtract a question mark from the name
string?

Again thanks!
 
B

Bon4ire

I meant to ask how to export the file without the question mark in the
filename while retaining the question mark in the exported jpg image.

Thanks
 
B

Bon4ire

Super thanks!

Steve said:
One more round of mods below ... Enjoy!


Sub ExportSlidesWithTitlesAsFileNames()
Dim Pres As Presentation
Dim Sld As Slide
Dim FilePath As String
Dim FileName As String

' Add error handler in case slide name contains
' characters not allowable in file names
On Error Resume Next

Set Pres = ActivePresentation
FilePath = Environ("HOMEDRIVE") + Environ("HOMEPATH") + "\"
For Each Sld In Pres.Slides
FileName = ""

' If Sld.Shapes.HasTitle Then
' If Sld.Shapes.Title.HasTextFrame Then
' If Sld.Shapes.Title.TextFrame.HasText Then
' FileName = Sld.Shapes.Title.TextFrame.TextRange.Text
' End If
' End If
' End If

If FileName = "" Then
FileName = Sld.Name
End If

' now eliminate illegal characters
FileName = Replace(FileName, "?", "_")
FileName = Replace(FileName, "*", "_")
FileName = Replace(FileName, ",", "_")
' repeat for any other characters that prove troublesome

FileName = FileName + ".jpg"
Sld.Export FilePath + FileName, "jpg"
Next
End Sub



-----------------------------------------
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