Wednesday, May 20, 2009

Save Powerpoint Slides as Images using VBA

VBA Code to Convert Ppwerpoint Slide to Image (JPEG)

Here is a simple code that will Export all slides in a powerpoint presentation to Jpeg files

Sub Save_PowerPoint_Slide_as_Images()

Dim sImagePath As String
Dim sImageName As String
Dim oSlide As Slide '* Slide Object
Dim lScaleWidth As Long '* Scale Width
Dim lScaleHeight As Long '* Scale Height

On Error GoTo Err_ImageSave

sImagePath = "C:\ForBlogger\"
For Each oSlide In ActivePresentation.Slides
sImageName = oSlide.Name & ".jpg"
oSlide.Export sImagePath & sImageName, "JPG"

Next oSlide

Err_ImageSave:
If Err <> 0 Then
MsgBox Err.Description
End If

End Sub


7 comments:

  1. PowerPoint comes with the ability to do this. Just do Save As, and for "Save as type:" choose JPG.

    ReplyDelete
  2. Anonymous5:46 PM

    Is there a way to know the names of Image files that will be stored as JPEGs/PNGs using Powerpoint Export option

    ReplyDelete
  3. Nice! Is there a way to add a count down timer to a PowerPoint Presentation lets say 25min when a button is pressed. I want to use this on my presentation to time my students when answering questions. Thank you!

    ReplyDelete
  4. Well that's nice, but can I save a slide as a picture and add a date in the file name ?

    ReplyDelete
  5. Is there a way to get this to save and name based off of a piece of text in the slide?

    ReplyDelete
    Replies
    1. You can change it in the following lines of code:

      sImageName = oSlide.Name & ".jpg"
      oSlide.Export sImagePath & sImageName, "JPG"

      Instead of oSlide.Name you can either enter a predetermined name using quotations i.e "text"

      For what you want though you will need to set a variable i.e

      Dim txt_text As String

      Set txt_text = ActivePresentation.Slides(1).Shapes("SlideText")

      The only issue you may have with this way of doing things is if the text box you are calling has alot of text. If its just a title it will be fine.
      Hope this helps

      Delete
  6. how to run this VBA.

    ReplyDelete

StumbleUpon
Share on Facebook
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.