HI,
I have hundred's of pptx files along with excel files in a folder. I want to convert all selected pptx files into individual hd videos(in mp4 format) and save into another folder by using vba. pls help.
Note: iam using office 2016.
i wrote a code for this. but few lines of code is not working properly (code colored with blue) pls go through the below code and help me.
Code:
Option Explicit
Sub GetFolderPath()
Dim InputFolder As String
Dim OutputFolder As String
Dim fd1, fd2 As FileDialog
Dim cpath, dpath As String
Dim FileInFromFolder As Object
Dim fil As Scripting.File
Dim cfolder, dfolder As Scripting.Folder
'-----------------------------------------------------------------------------------------
Dim fso As Scripting.filesystemobject
Dim actionclicked As Boolean
Set fso = New Scripting.filesystemobject
Set fd1 = Application.FileDialog(msoFileDialogFolderPicker)
Set fd2 = Application.FileDialog(msoFileDialogFolderPicker)
fd1.Title = "pick the folder to save files into"
fd1.AllowMultiSelect = False
actionclicked = fd1.Show
If actionclicked Then
InputFolder = fd1.SelectedItems(1)
Else
MsgBox "You didn't pick a folder"
Exit Sub
End If
If InputFolder = "" Then
MsgBox "Select a folder then click Yes"
Exit Sub
End If
cpath = InputFolder
Set fso = New Scripting.filesystemobject
Set cfolder = fso.GetFolder(cpath)
cpath = Replace(cpath, "\\", "\")
Debug.Print cfolder
Set fd2 = Application.FileDialog(msoFileDialogFolderPicker)
fd2.Title = "pick the folder to save files into"
fd2.AllowMultiSelect = False
actionclicked = fd2.Show
If actionclicked Then
OutputFolder = fd2.SelectedItems(1)
Else
MsgBox "You didn't pick a folder"
Exit Sub
End If
If OutputFolder = "" Then
MsgBox "Select a folder then click Yes"
Exit Sub
End If
dpath = OutputFolder
Set fso = New Scripting.filesystemobject
Set dfolder = fso.GetFolder(dpath)
dpath = Replace(dpath, "\\", "\")
'Debug.Print dfolder
For Each fil In cfolder.Files
If Left(fso.GetExtensionName(fil.Path), 2) = "pp" And Format(fil.DateLastModified, "dd/mm/yyyy") = Format(Date, "dd/mm/yyyy") Then
Application.ActivePresentation.SaveAs _
FileName:=dpath & "\" & fil.Name & ".mp4", _
FileFormat:=ppSaveAsMP4
End If
Next
End Sub
Thank you in advance.