I've got 300+ PowerPoint files in a folder. I want to open them one by one, export them to video, then close the PowerPoint files once the export is done.
I've seen numerous sample VBA code that open all the files at one go, do the export & don't close the files. I foresee that this method will not work for me as my pc will crash if all 300+ files are opened & exported at the same time.
This is a sample code that I picked up from this site. I need your help to edit it. I've got no experience in VBA so I've no idea how to loop it properly. Thanks.
Sub exportvideo()
Dim strFileName As String
Dim strFolderName As String
Dim PP As Presentation
'set default directory
strFolderName = Environ("USERPROFILE") & "\Desktop\New folder\"
strFileName = Dir(strFolderName & "\*.pptx")
Do While Len(strFileName) > 0
Set PP = Presentations.Open(strFolderName & "\" & strFileName)
'code to export to video
PP.CreateVideo FileName:=strFolderName & strFileName & ".mp4", _
UseTimingsAndNarrations:=True, _
VertResolution:=1024, _
FramesPerSecond:=30, _
DefaultSlideDuration:=5, _
Quality:=100
strFileName = Dir
Loop
'PP.Close
End Sub
I'm running PowerPoint 2016 on Windows 10.