#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=PPConverter.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include #include #include #include #include ;Main Code Body Global $listing Global $Total_Files $directory = FileSelectFolder("Choose Folder to Search for Powerpoint Files", "") if @error then Exit ;Create an array of files based on the parent directory you choose list($directory, 0) $listing = StringTrimRight($listing, 1) $listing = _StringExplode($listing, "|", 0) _ArraySort($listing) ;Put a message box up prior to starting the conversion MsgBox($MB_SYSTEMMODAL, "CONVERSION", " " & $Total_Files & " PowerPoint Files Found" & @CRLF & " Press OK To Begin") ;Open Powerpoint Application Global $oPPT = _PPT_Open() ;Main Loop that goes through each file and converts it from 4x3 to 16x9 For $iCount = 0 To $Total_Files - 1 File_Converter($listing[$iCount]) Next ;Close the Powerpoint Application _PPT_Close($oPPT) ;This Function builds a List of all the files to be converted including sub directories Func list($path = "", $counter = 0) $counter = 0 $path &= '\' Local $Check_File_Type_ppt Local $Check_File_Type_pptx Local $list_files = '', $file, $demand_file = FileFindFirstFile($path & '*') If $demand_file = -1 Then Return '' While 1 $file = FileFindNextFile($demand_file) If @error Then ExitLoop If @extended Then If $counter >= 10 Then ContinueLoop list($path & $file, $counter + 1) Else $Check_File_Type_pptx = StringRight($file,5) $Check_File_Type_ppt = StringRight($file,4) if ($Check_File_Type_pptx = ".pptx" or $Check_File_Type_ppt = ".ppt") Then $Total_Files = $Total_Files + 1 $listing &= $path & $file & "|" Endif EndIf WEnd FileClose($demand_file) EndFunc ;This Function converts the files from 4x3 to 16x9 and resizes the image in the file Func File_Converter($File_Name) Local Const $PpSlideSizeOnScreen16x9 = 15 ;Set a variable to represent the 16x9 format Local $New_File_Name = $File_Name Local $Check_File_Type_ppt ;Set a variable with the file path and name to be opened Local $sPresentation = $File_Name ;Open up the Powerpoint file Local $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation, True) if @error then ConsoleWrite ("Failed to Open Presentation"& @CRLF ) ;Change the powerpoint to a 16 x 9 format $oPresentation.PageSetup.SlideSize = $PpSlideSizeOnScreen16x9 ;Loop thtough all images and adjust them to the full screen size Local $curSlide, $curShape For $curSlide In $oPPT.ActivePresentation.Slides For $curShape In $curSlide.Shapes With $curShape ;Resize the image in the slide .LockAspectRatio = False .ScaleHeight(3.38, True) .ScaleWidth(5.13, True) .Rotation = 0 .Left = 0 .Top = 0 EndWith Next ; curShape Next ; curSlide ;Parse new File Name $Check_File_Type_ppt = StringRight($New_File_Name, 3) ConsoleWrite ("Last 3 characters of a file"& $Check_File_Type_ppt & @CRLF ) if ($Check_File_Type_ppt = "ppt") Then $New_File_Name = StringTrimRight($New_File_Name, 4) else $New_File_Name = StringTrimRight($New_File_Name, 5) EndIf ;SaveAs the Powerpoint with a new filename $New_File_Name = $New_File_Name & "(16x9)" _PPT_PresentationSaveAs($oPresentation, $New_File_Name,$ppSaveAsPresentation, True) if @error then ConsoleWrite ("Failed to SaveAs Presentation"& @CRLF ) ;Close the new Powerpoint file _PPT_PresentationClose($oPresentation) if @error then ConsoleWrite ("Failed to Close Presentation"& @CRLF ) EndFunc