Consulting

Results 1 to 3 of 3

Thread: Saving each slide as jpg with the text in the slide as file name

  1. #1
    VBAX Newbie
    Joined
    Apr 2018
    Posts
    1
    Location

    Saving each slide as jpg with the text in the slide as file name

    I have a powerpoint file where I want to save each of the individual slides as jpgs. That bit is fine. The issue is I want the file names to be the text on the individual slide. So if a slide has the text 'Hello There' I want the slide to save as hello-there.jpg (all in lower case, up to 25 characters). Is there any way to do this? Is there any sample VBA script that anyone is aware of that does something similar so I'm not starting from scratch. I'm pretty new to this but willing to give it a go. Know a little VBA. Thanks in advance.

  2. #2
    VBAX Wizard
    Joined
    Apr 2007
    Posts
    5,867
    Location
    Where is the text on the slide located? i.e. in what/which 'container'?

    A textbox? Which one? How to identify it?

    A Placeholder? Which one?

    A Shape? ...... etc.


    What if the text contains non-file characters? e.g. \ or / or * etc?
    Paul

    ------------------------------------------------------------------------------------------------------------------------
    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s)
    (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Wizard
    Joined
    Apr 2007
    Posts
    5,867
    Location
    If the 'text' in in the slide's title placeholder, then something like this

    All depends on where the text is and how it can be identified


    Option Explicit
    
    Sub SaveEach()
    
        Dim oPresentation As Presentation
        Dim oSlide As Slide
        Dim oShape As Shape
        Dim sFilename As String
    
        Set oPresentation = ActivePresentation
        
        For Each oSlide In oPresentation.Slides
            For Each oShape In oSlide.Shapes
            With oShape
                If .Type = msoPlaceholder Then
                    If .PlaceholderFormat.Type = ppPlaceholderCenterTitle Or _
                        .PlaceholderFormat.Type = ppPlaceholderTitle Then
                        If .HasTextFrame Then
                            If .TextFrame.HasText Then
                                sFilename = Left(LCase(.TextFrame.TextRange.Text), 25) & ".jpg"
                                On Error Resume Next
                                Kill sFilename
                                On Error GoTo 0
                                oSlide.Export sFilename, "jpg"
                                End If
                            End If
                        End If
                    End If
            End With
            Next
        Next
     
    
    End Sub
    Attached Files Attached Files
    Paul

    ------------------------------------------------------------------------------------------------------------------------
    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s)
    (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •