0
votes

For example: export slide number 30 up to 80 (export to mp4). some macro for that? Or: export only one section.

I found a macro that exports slides by sections, but it is in png and when I switch to mp4 it doesn't work. (Rodrigo Moraes macro).

Sub Test_Export()                                                          
                                                                           
Dim sld As Slide
i = 1
                                                                
DesiredSection = SectionIndexOf("Test")
                                                                           
For Each sld In ActivePresentation.Slides
                                                                            
If sld.sectionIndex = DesiredSection Then
   ActivePresentation.Slides(i).Export filenamepng & "TEST" & i & ".png", "PNG"
End If
                                                                             
i = i + 1
                                                                          
Next
                                                                           
                                                                           
End Sub
                                                                      
Function SectionIndexOf(sSectionName As String) As Long
    Dim x As Long
    With ActivePresentation.SectionProperties
        For x = 1 To .Count
            If .Name(x) = sSectionName Then
                SectionIndexOf = x
            End If
        Next
    End With                                                                   
End Function

A user (Albert Floor) is able to export selected slides to PDF with this macro

Private Sub CommandButton4_Click()
Dim myInput As String
Dim savePath As String\

'Name of Student
myInput = ActivePresentation.Slides(1).Shapes("TextBox2").OLEFormat.Object.Text\

'Location of saved file
savePath = ActivePresentation.Path & "\" & myInput & " Antwoorden Virtueel Lab" & ".pdf"  \\\\

'Select path student took
If ActivePresentation.Slides(9).Shapes("TextBox1").OLEFormat.Object.Text = "PRARDT" Then

'Change view
ActivePresentation.SlideShowWindow.View.Exit

'Prevents error 
ActiveWindow.Panes(1).Activate

'Select specific slides
ActivePresentation.Slides.Range(Array(9, 11, 15)).Select

'save selected slides as PDF
ActivePresentation.ExportAsFixedFormat Path:=savePath, FixedFormatType:=ppFixedFormatTypePDF, RangeType:=ppPrintSelection

MsgBox "file saved"

Else
MsgBox "wont work"

End If

End Sub
1
Is there any reason you can't make a copy of the slideshow, delete the slides you don't want, and then record it with OBS or similar?Beefster
Can you give more explanation about what issue you're having and what you hope the macro could do?Marcucciboy2
Looks like you are new here. Please read this guide on how to ask a question that will get good answers: stackoverflow.com/help/how-to-askHackSlash
@Beefster About deleting slides, I have many of them and with videos / images, so when I try to delete I have to wait a long time and often PowerPoint stops working and I have to close it. I record with OBS, but I do massive work, this recording time throughout the day takes me a long time. For this reason I open several powerpoints in Sandboxie to export several videos at the same time. I'm following it this way because PowerPoint can't use even 40% of my hardware constantly, I've already asked for help in Microsoft support and executed numerous tutorials, but it didn't work.Leo
@Marcucciboy2 I'm having trouble doing massive mp4 export. When trying to delete multiple slides it takes a long time and sometimes crashes because I have many slides with videos / images. I hope a macro will allow me to export specific slides to mp4 to work around all these problems. For example: export slide number 30 up to 80 (export to mp4).Leo

1 Answers

0
votes

I've never exported a powerpoint presentation to mp4 but in powerpoint 2013, the version I have, you seem to be able to create an mp4 when you Save As.

Save as honours hidden slides. So some simple code to hide slides then save as works, here is some sample code. In this example I hide all slides after the fifth.

Public Sub Savetomp4()
    Dim mySlides As slides
    Set mySlides = ActivePresentation.slides
    Dim aSlide As Slide
    
    ' Hide some slides
    For i = 0 To mySlides.Count - 1
       If i > 5 Then
           Set aSlide = mySlides.Item(i)
           aSlide.SlideShowTransition.Hidden = msoTrue
       End If
    Next i
    
    ' Save as mp4
    ActivePresentation.SaveAs "c:\temp\test.mp4", ppSaveAsMP4
    Debug.Print "Done!"
End Sub