-
Posts
15 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
alexanr1's Achievements

Seeker (1/7)
0
Reputation
-
Sorry. Still learning this site, which is a VERY COOL site!
-
#Include <PowerPoint.au3> #include <Constants.au3> #include <String.au3> #include <Array.au3> #include <File.au3> ;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
-
alexanr1 reacted to a post in a topic: Rewrite of the PowerPoint UDF
-
Got some feedback on my code formatting I think I cleaned it up based on the editors settings for tab's -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #Include <PowerPoint.au3> #include <Constants.au3> #include <String.au3> #include <Array.au3> #include <File.au3> ;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 PowerPoint Converter (4x3 to 16x9).au3
-
I am not following? Are you referring to how I am indenting?
-
I added in the ability to convert .ppt and .pptx files in case someone had old powerpoint files. Did the Open once and close once as well. ------------------------------------------------------------------------------------------- #Include <PowerPoint.au3> #include <Constants.au3> #include <String.au3> #include <Array.au3> #include <File.au3> ;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 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") ;Create a Powerpoint object 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 program _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) ; Set a variable to represent the 16x9 format Local Const $PpSlideSizeOnScreen16x9 = 15 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
-
Good Advice
-
Thought I would share with you the final version I have made. I need to go out to the church building and run it on our computer out there. I tested it with a couple scenarios and it seemed to work great! Thanks again for the help! I am going to find a way to share this with other churches as well who may own the older versions of the songs and are looking for a way to convert their files. - Rich --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #Include <PowerPoint.au3> #include <Constants.au3> #include <String.au3> #include <Array.au3> #include <File.au3> Global $listing Global $Total_Files $directory = FileSelectFolder("Choose Folder to Search for Powerpoint Files", "") if @error then Exit list($directory, 0) $listing = StringTrimRight($listing, 1) $listing = _StringExplode($listing, "|", 0) _ArraySort($listing) MsgBox($MB_SYSTEMMODAL, "CONVERSION", " " & $Total_Files & " PowerPoint Files Found" & @CRLF & " Press OK To Begin") For $iCount = 0 To $Total_Files - 1 File_Converter($listing[$iCount]) Next ;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 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 = StringRight($file,5) if ($Check_File_Type = ".pptx") 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) ; Set a variable to represent the 16x9 format Local Const $PpSlideSizeOnScreen16x9 = 15 local $New_File_Name = $File_Name ;Create a Powerpoint object Local $oPPT = _PPT_Open() ;Set a variable with the file path and name to be opened Local $sPresentation = "C:\PowerPoint Converter\4by3.pptx" 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 .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 $New_File_Name = StringTrimRight($New_File_Name, 5) ;Save the Powerpoint with a new filename $New_File_Name = $New_File_Name & "(16x9).pptx" _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 ) ;Close the Powerpoint program _PPT_Close($oPPT) EndFunc PowerPoint 4x3 to 16x9 Converter.au3
-
You are awesome! Thanks. The only thing I changed was I $mosTrue and #msoFalse, I just used the Boolean True and False Constants Thanks again. I am going to see if I can add a little more automation to it and traverse a directory and fix all the files I have. Its for a library of songs we use at my church. Its an older library and everything is in 4x3. It would take hours to open every one up and fix them, so I was wanting to use this to fix them all. Have a Happy Newyear!
-
alexanr1 changed their profile photo
-
I use to be a C developer. These Modern OO languages give me fits. It have a hard time finding how to call a method properly and struggle to look up correctly I got this VBA code (BELOW) to work in Powerpoint as a macro. What is the trick to translate it into autoit code? I greatly appreciate the help and I am slowly picking up on how this stuff works. - Rich -------------------------------------------------------------------------- Sub IMAGE_ADJUST() Dim curSlide As Slide Dim curShape As Shape For Each curSlide In ActivePresentation.Slides For Each curShape In curSlide.Shapes With curShape .LockAspectRatio = msoFalse .ScaleHeight 3.38, msoTrue .ScaleWidth 5.13, msoTrue 'position: .Rotation = 0 .Left = 0 .Top = 0 End With Next curShape Next curSlide End Sub
-
Got it to work! My only new challenge is the image on the Powerpoint slide is not being maximized. Curious if that is a paramater I can pass? Here is the test code BTW... -------------------------------------------------------- #Include <PowerPoint.au3> #include <Constants.au3> #include <File.au3> Global $oPPT = _PPT_Open() Global $sPresentation = "C:\PowerPoint Converter\4by3.pptx" Global Const $PpSlideSizeOnScreen = 1 Global Const $PpSlideSizeOnScreen16x10 = 16 Global Const $PpSlideSizeOnScreen16x9 = 15 ConsoleWrite ("@error=" & @error & @CRLF ) Global $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation, True) ConsoleWrite ("Opening Presentation" & @CRLF ) ConsoleWrite ("@error=" & @error & @CRLF ) if @error then ConsoleWrite ("Failed to Open Presentation"& @CRLF ) $oPresentation.PageSetup.SlideSize = $PpSlideSizeOnScreen16x9 _PPT_PresentationSaveAs($oPresentation, "C:\PowerPoint Converter\16by9",$ppSaveAsPresentation, True) ConsoleWrite ("Doing a Save AS" & @CRLF ) ConsoleWrite ("@error=" & @error & @CRLF ) _PPT_PresentationClose($oPresentation) ConsoleWrite ("Closing File" & @CRLF ) ConsoleWrite ("@error=" & @error & @CRLF )
-
Thanks for helping BTW. I appreciate it!. I am new to AutoIT. One additional assumption. When I "open" up an existing powerpoint, the $presentation variable I am using is just a pointer to the file. What I was thinking I would need to do is "read in" the slides and then manipulate each accordingly. I probably don't fully understand the AUTOIT language.
-
"C:\PowerPoint Converter\My Code to fix slides.au3" (13) : ==> Variable must be of type "Object".: $presentation.PageSetup.SlideSize = $PpSlideSizeOnScreen16x9 $presentation^ ERROR ->16:54:39 AutoIt3.exe ended.rc:1 +>16:54:39 AutoIt3Wrapper Finished. >Exit code: 1 Time: 3.112
-
#include <Constants.au3> #Include <PowerPoint.au3> Global $presentation Global Const $PpSlideSizeOnScreen = 1 Global Const $PpSlideSizeOnScreen16x10 = 16 Global Const $PpSlideSizeOnScreen16x9 = 15 _PPT_PresentationOpen($presentation, "C:\PowerPoint Converter\4by3.pptx") MsgBox($MB_SYSTEMMODAL, "OUTPUT", "Opening Pres" & @CRLF ) $presentation.PageSetup.SlideSize = $PpSlideSizeOnScreen16x9 MsgBox($MB_SYSTEMMODAL, "OUTPUT", "Setting Slide Size" & @CRLF ) _PPT_PresentationSaveAs($presentation,"C:\PowerPoint Converter\16x9.pptx") MsgBox($MB_SYSTEMMODAL, "OUTPUT", "Doing a Save AS" & @CRLF ) _PPT_PresentationClose($presentation) MsgBox($MB_SYSTEMMODAL, "OUTPUT", "Closing File" & @CRLF )
-
Getting an error. It seems like it wants me to build a complete new object and then update the values within the new object? Am I mis-intrepreting the error? "C:\PowerPoint Converter\My Code to fix slides.au3" (13) : ==> Variable must be of type "Object".: $presentation.PageSetup.SlideSize = $PpSlideSizeOnScreen16x9 $presentation^ ERROR ->11:20:37 AutoIt3.exe ended.rc:1 +>11:20:37 AutoIt3Wrapper Finished.
-
I am looking for a powerpoint function to change the presentation from 4:3 to 16:9. I thought I would find it within the PowerPoint.au3 but can't seem to find an routine that has the ability to change this for the presentation. Help? Thanks in advance, Rich